1

I have the following latex code:

\documentclass{beamer}
\usetheme{Frankfurt}

\usepackage{listings}

\lstset{ basicstyle = \linespread{1}\ttfamily, breaklines=true, postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}}, }

\begin{document}

\begin{frame}[fragile]{Title}

\begin{lstlisting} Really really really really really really long line next line \end{lstlisting}

\end{frame}

\end{document}

This works only if I comment out the postbreak, but if I leave it in, I get 162(!) errors. Some of these are "Missing number, treated as zero.", "Illegal unit of measure (pt inserted).", and "Missing = inserted for \ifnum.".

If I remove 'long line' from the first line, it suddenly works, albeit with many errors.

I am so confused and have no clue what's going on. Could I get some help? Thanks!

  • your code can not be tested as we don't have the py file. – Ulrike Fischer Nov 15 '20 at 12:54
  • Right, I don't want to post the specific program, but I'll add into the post that it seems to file whenever the program is 'big enough'. If I use
    \lstinputlisting[lastline = 4, language=Python]{program.py}
    

    instead, it works, but anything bigger than 5 doesn't. Even with the shortened code, there's still over 100 errors.

    – Biggly Bobb Nov 15 '20 at 12:57
  • 1
    then why don't you use a lstlisting environment and one long line in your example? – Ulrike Fischer Nov 15 '20 at 12:58
  • Thanks, that's a good point. I've edited the post further. – Biggly Bobb Nov 15 '20 at 13:05

1 Answers1

2

The number of errors is quite irrelevant, normally only the first matters and the rest are follow up errors.

Store the arrow in a box:

\documentclass{beamer}
\usetheme{Frankfurt}

\usepackage{listings}

\newsavebox\mypostbreak \savebox\mypostbreak{\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}}} \lstset{ basicstyle = \linespread{1}\ttfamily, breaklines=true, postbreak=\usebox\mypostbreak, }

\begin{document}

\begin{frame}[fragile]{Title} \begin{lstlisting} aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaaaa \end{lstlisting} \end{frame}

\end{document}

enter image description here

Ulrike Fischer
  • 327,261