1

I'm writing a Latex file. But when I try to add the following code to the file, it just can't compile anymore:

\begin{lstlisting}[language=bash,caption={bash version}]
btcd --txindex --simnet --rpcuser=kek --rpcpass=kek
\end{lstlisting}

I get these errors:

Illegal parameter number in definition of \lst@insertargs.

<to be read again> 
}
l.241 }
     
You meant to type ## instead of #, right?
Or maybe a } was forgotten somewhere earlier, and things
are all screwed up? I'm going to assume that you meant ##.
Illegal parameter number in definition of \lst@arg.

<to be read again> 
}
l.241 }
     
You meant to type ## instead of #, right?
Or maybe a } was forgotten somewhere earlier, and things
are all screwed up? I'm going to assume that you meant ##.
Runaway argument?

! Paragraph ended before \lst@next was complete.
<to be read again> 
\par 
l.241 }
     
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.

Here is the file:

\documentclass[ngerman, openany]{scrbook}
\usepackage[utf8]{inputenc}
\input{../shared/expl-cfg}
\input{expl/switch-cfg}
\begin{document}

\ifthenelse{\boolean{isPresentation}}{
    \chapter{Wirtschaft von Kryptowährungen}        
}{
\chapter{Analyse}\label{sec:analyse}

\section{Struktur des Lightning Network}
insert something here
\section{Funktionsweise des Lightning Networks}
insert something here
\section{Implementierung eines Lightning Networks in einem privaten Blockchain}
insert something here
\begin{lstlisting}[language=bash,caption={bash version}]
btcd --txindex --simnet --rpcuser=kek --rpcpass=kek
\end{lstlisting}
}
\end{document}

here is the ../shared/expl-cfg:

\typeout{This is twp-cfg, the common configuration file (JHf)}
\makeatletter

\usepackage{ifthen}
\usepackage{iftex}
\usepackage{listings}                 

Edit: Here is the switch-cfg file.

\csname SwitchCfgLoaded\endcsname
\let\SwitchCfgLoaded\endinput

\newboolean{isBook}            
\newboolean{isPresentation}
\makeatletter                   
\@ifclassloaded{scrbook}{       
  \setboolean{isBook}{true}
}{                              
      \@ifclassloaded{beamer}{  
        \setboolean{isPresentation}{true}
      }{}                      
}

\ifthenelse{\boolean{isBook}}{
}{
  \let\frontmatter\relax
  \let\mainmatter\relax
  \let\backmatter\relax
  
    \let\chapter\section
    \let\section\subsection
    \let\subsection\subsubsection
      \ifthenelse{\boolean{isPresentation}}{
        \AtBeginSubsection[]{
          \begin{frame}<beamer|handout>%
              \begin{block}{}
                  \insertsubsectionhead
              \end{block}
          \end{frame}
        }{}
      }{}
}

How can I solve this issue? I get the same problem when using verbatim. I am using Overleaf and LuaLaTeX as compiler.

5
  • We can't compile that without expl/data/expl-poster.tex, and the first snippet by itself does not generate a problem for me, even with the same preamble. Please post a proper minimal working example
    – frabjous
    May 20, 2022 at 12:24
  • I edited the question and made it more readable
    – AidenFive
    May 20, 2022 at 12:54
  • 1
    @AidenFive Sorry, but isn't going to work like this. You load two “configuration files” and only show one of them. Try compiling the example without them (and removing the final stray }): does the issue remain? If so, it depends from something in those files. Assuming that the code produces the error to begin with.
    – egreg
    May 20, 2022 at 13:13
  • You need to add the ifthen package at least. Please test your code before you post.
    – frabjous
    May 20, 2022 at 13:50
  • I still don't get a PDF File even after adding \usepackage{ifthen}
    – AidenFive
    May 20, 2022 at 13:57

1 Answer 1

0

I believe you are encountering an issue with the listings package described here and here. This is preventing you from using the listing inside the \ifthenelse construction.

It does work however, if you revert to the plain TeX style conditionals:

\ifisPresentation%
    \chapter{Wirtschaft von Kryptowährungen}        
\else%
\chapter{Analyse}\label{sec:analyse}

\section{Struktur des Lightning Network}
insert something here
\section{Funktionsweise des Lightning Networks}
insert something here
\section{Implementierung eines Lightning Networks in einem privaten Blockchain}
insert something here
\begin{lstlisting}[language=bash,caption={bash version}]
btcd --txindex --simnet --rpcuser=kek --rpcpass=kek
\end{lstlisting}
\fi
\end{document}

Other things that also work include using \listinline instead:

\lstinline[language=bash,caption={bash version}]{btcd --txindex --simnet --rpcuser=kek --rpcpass=kek}

Or you could save the bash to a separate file (bashcmd.sh) and use:

\lstinputlisting[language=bash,caption={bash version}]{bashcmd.sh}

There may be other solutions in the answers to the questions at the links given above.

In the future, please don't break up your code into three separate files when there is no reason to do so in order to demonstrate your problem. All you did is make it harder for us to help you.

You must log in to answer this question.

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