[Tex/LaTex] getting an ‘Illegal parameter number’ error, here

errorslistings

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?!

Best Answer

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:

Related Question