9

I have following text MWE:

\documentclass[12pt,a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[color=red,opacity=0.1,contents={}]{background}
\usepackage{hyperref}
\usepackage{indentfirst}
\usepackage{caption}
\usepackage{listings}
\usepackage{tcolorbox}
\usepackage[slovene]{babel}
\usepackage{titlesec}

\setcounter{secnumdepth}{4}

\titleformat{\paragraph}
{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\author{Marko Frelih \\ Company name \\ \texttt{email}}
\title{Some manual}
\date{Ljubljana, Marec 2015}

\begin{document}
\maketitle
\thispagestyle{empty}
\pagebreak
\clearpage
\pagenumbering{arabic}

\AddEverypageHook{
  \ifnum\value{page}<1\relax
  \else
  \backgroundsetup{contents={ZAUPNO}}
  \fi
\BgMaterial
}

\subsection{Section with error}
Kot smo \v{z}e namignili v prej\v{s}njem poglavju, bo prva particija imela
datote\v{c}ni sistem \textit{FAT32}, druga \textit{ext4} ter tretja zopet \textit{FAT32}.
\textbf{OPOZORILO: \v{C}e je katerakoli particija priklopljena, jo moramo obvezno
odklopiti za ukazom:
\begin{lstlisting}[language=bash]
# sudo umount /dev/sdbx
\end{lstlisting}
, kjer je x \v{s}tevilka particije.}

\end{document}

If I try to compile this latex document, I get following errors:

! Illegal parameter number in definition of \reserved@a.
! Illegal parameter number in definition of \lst@insertargs.
! Illegal parameter number in definition of \lst@arg.
! Illegal parameter number in definition of \lst@arg.
! Illegal parameter number in definition of \lst@arg.
! Illegal parameter number in definition of \reserved@a.
! Illegal parameter number in definition of \lst@arg.
! Illegal parameter number in definition of \lst@arg.
! Illegal parameter number in definition of \lst@arg.

In document, all of this errors are detected in line 210, which is in our MWR line with text , kjer je x \v{s}tevilka particije.}. I've used \begin{lstlisting}[language=bash] and \end{lstlisting} before in document and there were no errors. What am I missing?!

13

You cannot have a lstlisting in the argument of \textbf.

In these cases use the \bfseries switch.

\documentclass[12pt,a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[slovene]{babel}
\usepackage[color=red,opacity=0.1,contents={}]{background}
\usepackage{indentfirst}
\usepackage{caption}
\usepackage{listings}
\usepackage{tcolorbox}
\usepackage{titlesec}
\usepackage{hyperref}


\setcounter{secnumdepth}{4}

\titleformat{\paragraph}
{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\author{Marko Frelih \\ Company name \\ \texttt{email}}
\title{Some manual}
\date{Ljubljana, Marec 2015}

\begin{document}
\maketitle
\thispagestyle{empty}
\pagebreak
\clearpage
\pagenumbering{arabic}

\AddEverypageHook{
  \ifnum\value{page}<1\relax
  \else
  \backgroundsetup{contents={ZAUPNO}}
  \fi
\BgMaterial
}

\subsection{Section with error}
Kot smo \v{z}e namignili v prej\v{s}njem poglavju, bo prva particija imela
datote\v{c}ni sistem \textit{FAT32}, druga \textit{ext4} ter tretja zopet \textit{FAT32}.
{\bfseries OPOZORILO: \v{C}e je katerakoli particija priklopljena, jo moramo obvezno
odklopiti za ukazom:
\begin{lstlisting}[language=bash]
# sudo umount /dev/sdbx
\end{lstlisting}
, kjer je x \v{s}tevilka particije.}

\end{document} 

enter image description here

As a side note, note the package loading order.

For further reading:

  • 1
    Some remarks about the package loading order should be necessary. – egreg Mar 11 '15 at 9:21
  • @egreg Do you mean hyperref too early and babel too late? – karlkoeller Mar 11 '15 at 9:44
  • Yes: I'd use fontenc, inputenc, babel, the others in any order, and of course hyperref last. – egreg Mar 11 '15 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.