Text FormattingEscape into latex from \lstinline?

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
gkl
Posts: 28
Joined: Sat Jan 17, 2009 12:21 am

Escape into latex from \lstinline?

Post by gkl »

Dear All,

I have a short snippet of code that I want to include inline with the rest of the text and I am using the listings package. I have the following LaTex code:

Code: Select all

\documentclass[a4paper,twoside,10pt]{article}
\usepackage{listings}
\begin{document}
\lstset{language=Prolog,escapechar=\%}
 This is a \lstinline!%$\mbox{Name}$%! test
\end{document}
that works fine in an lstlisting environment (the problem is that listings thinks Name is a Prolog variable and it prints in bold - I do not want that.

Is there any way to escape into LaTex so the code above will work as expected?

Regards,
George

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

Post Reply