由于错误,/etc/vsftpd.conf 列表未显示在 tcolorbox 中:

由于错误,/etc/vsftpd.conf 列表未显示在 tcolorbox 中:

我有以下 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}
\usepackage{float}

\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 \\ \texttt{email}}
\title{Install 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
}

\section{Test}
\begin{tcolorbox}[fontupper=\footnotesize,flushleft upper,boxrule=0pt,arc=0pt,left=2pt,right=2pt,colback=gray,after=\ignorespacesafterend\par\noindent]
anonymous_enable=NO
no_anon_password=NO
local_enable=YES
write_enable=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
chown_uploads=YES
chown_username=root
ls_recurse_enable=YES
listen=YES
\end{tcolorbox}

\end{document}

当我尝试编译文档时,出现以下错误:

! Missing $ inserted.
<inserted text>
$
l.404 anonymous_

! Missing $ inserted.
<inserted text>
$
l.415 \end{tcolorbox}

第一个错误位于行anonymous_enable=NO,第二个错误位于行 ,命令为\end{tcolorbox}。我遗漏了什么?

答案1

我猜你想在里面使用列表文本tcolorbox。为此,使用带有选项tcblisting的环境listing only而不是tcolorbox

\documentclass[12pt,a4paper]{article}

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

\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 \\ \texttt{email}}
\title{Install 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
}

\section{Test}
\begin{tcblisting}{listing only,fontupper=\footnotesize,flushleft upper,
  boxrule=0pt,arc=0pt,left=2pt,right=2pt,
  colback=gray!50,after=\ignorespacesafterend\par\noindent}
anonymous_enable=NO
no_anon_password=NO
local_enable=YES
write_enable=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
chown_uploads=YES
chown_username=root
ls_recurse_enable=YES
listen=YES
\end{tcblisting}

\end{document}

在此处输入图片描述

相关内容