Text FormattingHow to indicate a LaTeX command in LaTeX

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
frodojedi
Posts: 20
Joined: Fri Feb 18, 2011 1:23 am

How to indicate a LaTeX command in LaTeX

Post by frodojedi »

Dear all,
I need to write a document about LaTex and I need to indicate some LaTex commands inside my LaTex document without having such commands compiled in the usual way but just printed as it is written.

Just to give an example, how can I write the command \clearpage without having it working as usual but just printed out as normal text?

I know that there is the \begin{verbatim} option, but it does not work for my case.

My attempt is $\backslash$clearpage ...but I am not very sure...


Thanks in advance
Last edited by frodojedi on Sat Feb 19, 2011 3:43 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

How to indicate a LaTeX command in LaTeX

Post by frabjous »

frodojedi wrote: I know that there is the \begin{verbatim} option, but it does not work for my case.
Why not?

Or what about \verb|\clearpage| for the inline version?
My attempt is $\backslash$clearpage ...but I am not very sure...
Simply "\textbackslash clearpage" could be more natural approach along the same lines.

But see also the listings package and similar.
frodojedi
Posts: 20
Joined: Fri Feb 18, 2011 1:23 am

Re: How to indicate a LaTeX command in LaTeX

Post by frodojedi »

Hi thanks for answering.

\verb|\clearpage| is what I was searching for!
frodojedi
Posts: 20
Joined: Fri Feb 18, 2011 1:23 am

Re: How to indicate a LaTeX command in LaTeX

Post by frodojedi »

I get this error when putting \verb|\clearpage| inside the command \footnote{}

! LaTeX Error: \verb illegal in command argument.



Help!
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

How to indicate a LaTeX command in LaTeX

Post by frabjous »

See this thread for suggestions on dealing with that problem.
frodojedi
Posts: 20
Joined: Fri Feb 18, 2011 1:23 am

Re: How to indicate a LaTeX command in LaTeX

Post by frodojedi »

Thanks, it works!!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to indicate a LaTeX command in LaTeX

Post by localghost »

frodojedi wrote:Thanks, it works!!
Then please mark the topic (not the last post) accordingly as written in Section 3 of the Board Rules (to be read before posting).


Best regards and welcome to the board
Thorsten
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

How to indicate a LaTeX command in LaTeX

Post by Juanjo »

Even simpler with the help of the fancyvrb package. Check this example:

Code: Select all

\documentclass{article}
\usepackage{fancyvrb}
\DefineShortVerb{\|}
\VerbatimFootnotes
\begin{document}
The commands |\clearpage|, |\newpage| and |\pagebreak| have similar
purposes\footnote{There also exists the |\cleardoublepage| command.}, 
although there are essential differences among them.
\end{document}
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
Post Reply