I have been writing a project report and have added some pseudo codes using the following command : lstlisting in Latex as shown bellow.
\begin{lstlisting}[language=c++]
# On leave focus of email field
IF email is blank
Error message: "Please enter an email address"
ELSE IF email field value is not a valid email address
Error message: "Wrong email please try again"}
# On leave focus of password
IF password is not sufficiently strong
Error message: "Password strength is not good"
\end{lstlisting}
The above works just fine but in the code block thy are some line numbers appearing and I would like to get ride of those. Any hints on how to remove them? I also know the following:
\section*{New section}
Would give a section title without number. But in the case of code listing it doesn't work and produce an error instead.
The listings package offers source code highlighting for various languages. Learn by example how to use it in your LaTeX documents. The listings package is a powerful way to get nice source code highlighting in LaTeX.
- LaTeX-Tutorial.com Highlight source code in LaTeX with the lstlisting package. The listings package offers source code highlighting for various languages. Learn by example how to use it in your LaTeX documents. The listings package is a powerful way to get nice source code highlighting in LaTeX.
Simply specify the breaklines option on your snippet. The downside is that you have to process the document with the --shell-escape option because the external program pygmentize is used to format the source code. Thanks for contributing an answer to TeX - LaTeX Stack Exchange! Please be sure to answer the question.
The default tool to display code in LaTeX is verbatim, which generates an output in monospaced font. The code above produces the following output: Just as in the example at the introduction, all text is printed keeping line breaks and white spaces. There's a starred version of this command whose output is slightly different.
You used:
\begin{lstlisting}[language=c++]
Specifying that the language is C++, the same way you can specify you don't whant line numbers:
\begin{lstlisting}[language=c++,numbers=none]
In the code you posted this is not C++ and you said it is for pseudocode, so you can get rid of the language parameter and just keep:
\begin{lstlisting}[numbers=none]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With