我有以下文本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}
如果我尝试编译该乳胶文档,我会收到以下错误:
! 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.
在文档中,所有这些错误都出现在第 210 行,即我们的 MWR 行,其中包含文本。我之前在文档中, kjer je x \v{s}tevilka particije.}
使用过,没有出现任何错误。我遗漏了什么?!\begin{lstlisting}[language=bash]
\end{lstlisting}
答案1
lstlisting
在 的论点中不能有\textbf
。
在这些情况下请使用\bfseries
开关。
\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}
附注:请注意包的加载顺序。
进一步阅读: