![圈出 i 作为自定义项目标签给出了“缺失 }”错误](https://linux22.com/image/433553/%E5%9C%88%E5%87%BA%20i%20%E4%BD%9C%E4%B8%BA%E8%87%AA%E5%AE%9A%E4%B9%89%E9%A1%B9%E7%9B%AE%E6%A0%87%E7%AD%BE%E7%BB%99%E5%87%BA%E4%BA%86%E2%80%9C%E7%BC%BA%E5%A4%B1%20%7D%E2%80%9D%E9%94%99%E8%AF%AF.png)
我想定义一个自定义项目标签,它可以用于无序列表,并且看起来像一个“信息”符号。它应该是圆圈内的一个小写字母“i”。
我做了什么:
\documentclass[draft,a4paper]{book}
\usepackage[ngerman]{babel}
\usepackage{tikz}
\newcommand{\info}{\item[%
\begin{tikzpicture}
\node[draw,circle,inner sep=1pt]{i};
\end{tikzpicture}
]}
\begin{document}
\begin{itemize}
\info{info}
\end{itemize}
\end{document}
它给了我以下错误:
/main.tex:90: Argument of \tikz@fig@scan@options has an extra }.
<inserted text>
\par
l.90 \info
{info}
I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.
Runaway argument?
draw,circle,inner sep=1pt
./main.tex:90: Paragraph ended before \tikz@fig@scan@options was complete.
<to be read again>
\par
l.90 \info
{info}
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.
./main.tex:90: Extra }, or forgotten \endgroup.
<recently read> }
l.90 \info
{info}
I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.
./main.tex:90: Extra }, or forgotten \endgroup.
\sbox ...box {\color@setgroup #2\color@endgroup }
l.90 \info
{info}
I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.
./main.tex:90: Extra }, or forgotten \endgroup.
\endpgfpicture ...globally \endgroup \hss \egroup
\pgf@restore@layerlist@fro...
l.90 \info
{info}
I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.
./main.tex:90: Missing } inserted.
<inserted text>
}
l.90 \info
{info}
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.
./main.tex:90: Extra }, or forgotten \endgroup.
\endpgfpicture ...dpicture \endgroup \hss \egroup
\pgfsys@typesetpicturebox ...
l.90 \info
{info}
I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.
./main.tex:90: Missing } inserted.
<inserted text>
}
l.90 \info
{info}
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.
./main.tex:91: LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.91 \end{itemize}
Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.
./main.tex:91: LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.91 \end{itemize}
Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.
./main.tex:91: LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.91 \end{itemize}
Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.
./main.tex:91: LaTeX Error: \begin{tikzpicture} on input line 90 ended by \end{itemize}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.91 \end{itemize}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
随后出现了一些其他错误。
我真的不明白我哪里漏掉了“}”。这个错误是因为它位于项目标签选项内吗?
答案1
一个解决方案是继续使用itemize
并自定义项目符号。
\documentclass[draft,a4paper]{book}
\usepackage[ngerman]{babel}
\usepackage{tikz}
\newcommand{\info}{
\raisebox{-1pt}{
\begin{tikzpicture}
\node[draw,circle,inner sep=1pt]{i};
\end{tikzpicture}
}}
\begin{document}
\begin{itemize}
\item[\info] Hello
\item[\info] What are you looking for?
\end{itemize}
\end{document}
编辑
如果要正确对齐i
圆圈和文本,可以执行以下操作:
\documentclass[draft,a4paper]{book}
\usepackage[ngerman]{babel}
\usepackage{tikz}
\newcommand{\info}{
\begin{tikzpicture}[baseline=(content.base)]
\node[draw,circle,minimum width=5pt]{};
\node(content){i};
\end{tikzpicture}
}
\begin{document}
\begin{itemize}
\item[\info] Hello
\item[\info] What are you looking for?
\end{itemize}
\end{document}