我想使用 & 符号并引用(对内点周围的文本中的部分),但每当我尝试这样做时,文档都会编译为无限。
最小工作示例:
\documentclass{article}
\usepackage [ europeanresistors ]{ circuitikz }
\usepackage{tikz, pgfornament, tikzrput}
\usetikzlibrary{shapes.geometric,arrows,decorations, decorations.text}
\usepackage[textwidth=5cm,textheight=5cm,right=2.5cm,left=2.5cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{fix-cm}
\usepackage[colorlinks=true, allcolors=blue]{hyperref}
\begin{document}
\section{Introduction}\label{sec:intro}
\begin{figure}[htbp]
\begin{tikzpicture}
\draw[double distance=10mm](0,0) circle (2.3cm);
\node at (0,0,0,0) {This \& that \ref{sec:intro}};
\path [postaction={decorate,decoration={text along path, reverse path,text align=center, text={||Inner Ring 1 }}}] (-36:2.3cm) arc (-36:216:2.3cm);
\path [postaction={decorate,decoration={raise=-1ex,text along path, text align=right, text={||Inner Ring 2}}}] (-36:2.3cm) arc (-36:370:2.3cm);
\path [postaction={decorate,decoration={raise=-1ex,text along path, text align=right, text={||Inner Ring 3}}}] (-36:2.3cm) arc (-36:220:2.3cm);
%Not working:
%\path [postaction={decorate,decoration={raise=-1ex,text along path, text align=right, text={||This \& that \ref{sec:intro} 3}}}] (-36:2.3cm) arc (-36:220:2.3cm);
\end{tikzpicture}
\caption{This is a circle}
\label{fig:circle}
\end{figure}
\end{document}
答案1
表达中有两个问题
This \& that \ref{sec:intro} 3
第一个是 & 符号。修复很简单,用括号括起来:
This {\&} that \ref{sec:intro} 3
第二个是\ref
。一种解决方法是将节号转换为简单字符串。以下为什么我不能将 \ref*{} 扩展为字符串?, 你可以试试:
\edef\introsectionnumber{\getrefnumber{sec:intro}}
前
This {\&} that \introsectionnumber{} 3
因此这应该可行:
% working:
\edef\introsectionnumber{\getrefnumber{sec:intro}}
\path [postaction={decorate,decoration={raise=-1ex,text along path, text align=right, text={||This {\&} that \introsectionnumber{} 3}}}] (-36:2.3cm) arc (-36:220:2.3cm);