0

I code this in a .tex file.

\begin{lstlisting}
  % This is the syntax for inserting code.
  \begin{lstlisting}
  \end{lstlisting}
\end{lstlisting}

And this is what I expect:

  % This is the syntax for inserting code.
  \begin{lstlisting}
  \end{lstlisting}

Unfortunately, this is not feasible. What is the correct format?

1
  • 1
    The question is clear. I don't see why it has been closed. It might be a duplicate, but I couldn't find it. Anyway, the solution is to do \lstnewenvironment{LSTLISTING}{}{} in the document preamble and use \begin{LSTLISTING}...\end{LSTLISTING} in order to show the usage of lstlisting.
    – egreg
    Nov 21, 2022 at 9:32

1 Answer 1

2

Welcome to TeX.SE...

Is the below match with your requirement:

\documentclass{book}
\usepackage{listings}
\begin{document}

\begin{verbatim}
  % This is the syntax for inserting code.
  \begin{lstlisting}
  \end{lstlisting}
\end{verbatim}

\end{document}

Not the answer you're looking for? Browse other questions tagged .