按照此:使双列列表与其部分从同一行开始,我做到了:
\documentclass{article}
\usepackage{cprotect}
\usepackage{tasks}
\begin{document}
\section{Languages}
\begin{tasks}[label = \textbullet](2)
\task C{}\verb!++!.
\task German (B1)
\task Italian (A1)
\task Greek (native)
\end{tasks}
\end{document}
这会导致错误:
./foo.tex:14: LaTeX Error: \verb illegal in command argument.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.14 \end{tasks}
?
我读过这个:如何将 \verb 命令放入 \textbf{} 块内?,但仍然无法应用解决方案,我尝试了:
\task \cprotect C{}\verb!++!.
但结果是:
Runaway argument?
{\task }{,label = \textbullet }{2} \task
./foo.tex:10: Forbidden control sequence found while scanning use of \tasks.
<inserted text>
\par
l.10 \task \cprotect
C{}\verb!++!.
?
如何解决这个问题?
答案1
用这个:
\usepackage{fancyvrb}
\newcommand\Cpp{C\Verb!++!}
但为什么不简单一点呢 C{}\texttt{++}
?