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}
\verb
command and theverbatim
environment? They are available without extra packages... of course they have no syntax highlighting...\verb
cannot be used and neitherbegin{verbatim}
... how can I use it? Most importantly, how did the guys that wroteThe LaTeX Companion
did it?\verb
correctly, you'd have no problem:\verb|\citeyear{peel_epidemiology_2011}|
verbatim
makes a text block the whole\linewidth
wide;\verb<char><text><char>
(where<char>
is not used in<text>
takes just the space it needs. See tex.stackexchange.com/questions/86568/…verbatim
environment doesn't make any sense in a cell declared to belong to anl
column.