0

I want to display a block of code with ' and ` displaying as themselves and with evaluation of macros.The closest that I've been able to come was

\documentclass[b4paper]{article}
\usepackage{alltt}
\usepackage{upquote}
\begin{document}
Using alltt and upquote
\begin{alltt}
foo='Ren\'{e}'
bar=`Ren\'{e}`
\end{alltt}
\end{document}

and

\documentclass[b4paper]{article}
\usepackage{fancyvrb}
\usepackage{upquote}

\begin{document}

Using upquote and fancyvrb
\begin{verbatim}
foo='Ren\'{e}'
bar=`Ren\'{e}`
\end{verbatim}

These correctly handle the ', ` and \, but the text is not indented nor in a frame.

I tried using upquote and fancyvrb with frame=single

\begin{verbatim}[frame=single]
foo='Ren\'{e}'
bar=`Ren\'{e}`
\end{verbatim}

\end{document}

These correctly handle the ', ` and \, but the text is not indented nor in a frame.

The placement of the optional parameter matches the fancyvrb documentation; [frame=single] is treated as the first text line in the environment. Putting the parameters in the other order gives me

! Missing $ inserted 
<inserted text> 
$ 
l.16

The error line seems to be \end{verbatim}

The documentation for listings says that it is possible to escape LaTeX, but I have not been able to get that to work.

I tried putting everything in a framed environment, but that interfered with alltt and fancyvrb.

I have to edit the document on a platform that only supports two code pages per boot, and I need 437 and 850 there.

So what is my best way forward?

1
  • You need Verbatim, not verbatim, to use fancyvrb options
    – mbert
    Commented Jul 12, 2023 at 18:12

1 Answer 1

0

This worked:

\documentclass[b4paper]{article}
\usepackage{alltt}
\usepackage{framed}
\usepackage{upquote}
\begin{document}

Using alltt

\begin{alltt}
foo='Ren\'{e}'
bar=`Ren\'{e}`
\end{alltt}

Using framed alltt

\begin{framed}
\begin{alltt}
foo='Ren\'{e}'
bar=`Ren\'{e}`
\end{alltt}
\end{framed}

\end{document}

I wanted to use fancyvrb, which lets me control the width, but it doesn't render properly. I'll use the stopgap above until I figure out how to escape to LaTeX in listings,

1
  • You can accept own answer.
    – Zarko
    Commented Dec 11, 2023 at 3:10

You must log in to answer this question.

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