下面的代码有什么错误?它给出:
Missing \endcsname inserted.
<to be read again>
\cs_set_nopar:Npx
l.34 \begin{bdoclatex}[KO]
使用的代码。
\documentclass{article}
\RequirePackage{tcolorbox}
\tcbuselibrary{minted}
\ExplSyntaxOn
\msg_set:nnnn { bdoc } { bdoclatex-unknown-formating }
{ Unknown ~ options ~ for ~ the ~ environment ~ bdoclatex. }
{ You ~ can ~ use ~ sbs (side-by-side), ~ code ~ or ~ std (standard). }
\NewDocumentCommand{\formatting}{m}{
\str_case:nnF { #1 } {
{sbs}{listing ~ side ~ text}
{code}{listing ~ only}
{std}{listing ~ and ~ text } % What to add here ?
} {
\msg_error:nn { bdoc } { bdoclatex-unknown-formating }
}
}
\ExplSyntaxOff
\newtcblisting{bdoclatex}[1][std]{%
\formatting{#1}
}
\begin{document}
\begin{bdoclatex}[sbs]
$A = B + C$
\end{bdoclatex}
\begin{bdoclatex}[KO]
$A = B + C$
\end{bdoclatex}
\end{document}
答案1
您使用了错误的工具。
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{minted}
\tcbset{
sbs/.style=listing side text,
code/.style=listing only,
std/.style=listing and text,
}
\newtcblisting{bdoclatex}[1][std]{#1}
\begin{document}
\begin{bdoclatex}[sbs]
$A = B + C$
\end{bdoclatex}
\begin{bdoclatex}[code]
$A = B + C$
\end{bdoclatex}
\begin{bdoclatex}[std]
$A = B + C$
\end{bdoclatex}
\begin{bdoclatex}
$A = B + C$
\end{bdoclatex}
\begin{bdoclatex}[KO]
$A = B + C$
\end{bdoclatex}
\end{document}
最后一个你得到了标准
! Package pgfkeys Error: I do not know the key '/tcb/KO' and I am going to
ignore it. Perhaps you misspelled it.