I wanted to typeset LaTeX code directly into my document, but without it doing something, i.e., I just want to show my code in the output.
Now, I know there is the verbatim
environment for code, as well as the listings
package for this, but I am wondering what the best method for typesetting LaTeX code directly is (if there is one), without needing any extra packages.
A few days ago I tried to do it inside a table, and I came up with this question: Print small TeX code verbatim and render it
but still, they managed to do something different, as it automatically included the showcase.
I just want to be able to write a LaTeX code snippet easily and inside a normal environment, say, tables
. What is the best way to do it?
MWE
\documentclass{report}
\usepackage{booktabs}
\begin{document}
\begin{table}[tbhp]
\centering
\caption{Citing with FEUPPHDTESES.STY}\label{tab:Citing}
\begin{tabular}{ll}
\toprule
Command & Result\\
\midrule
\texttt{citeplist} & \verb\citeplist{peel_epidemiology_2011,espinoza2012inverse,espinoza2012optimization}\\
\texttt{citet} & \verb\citet{peel_epidemiology_2011,espinoza2012inverse,espinoza2012optimization}\\
\texttt{citep} & \verb\citep{peel_epidemiology_2011,espinoza2012inverse,espinoza2012optimization}\\
\texttt{citeyear} & \verb\citeyear{peel_epidemiology_2011}\\
\texttt{citeauthor} & \verb\citeauthor{peel_epidemiology_2011}\\
\texttt{citetlist} & \verb\citetlist{peel_epidemiology_2011,espinoza2012inverse,espinoza2012optimization}\\
\texttt{citeplist} & \verb\citeplist{peel_epidemiology_2011,espinoza2012inverse,espinoza2012optimization}\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
Best Answer
The syntax for
\verb
iswhere
<char>
should be a (non special) character not found in<text>
. Most often|
or+
are used for<char>
.A
verbatim
environment doesn't make sense in a table cell belonging to a column declared asl
,c
orr
, just like aquote
environment doesn't make sense in the argument to\mbox
.If you have multiline verbatim to be used in a cell column, you need to use a
p
column, but with some adjustments.