我需要一个以下(出于 MWE 原因)简化类型的大家族对象。
% \section{
Whatever description for $F_{q
\raisebox{-.1cm}{\tikz[scale=.25] {
\draw [red,double] (1,0) -- (0,1) ;
\draw [blue,double, ] (0,0) -- (1,1) ;
\draw [violet,double] (2,0) -- (1,1) ;
\draw [green,double, ] (1,0) -- (2,1) ;
}}r}$
% }
% \subsection{
Whatever description for $F_{q
\raisebox{-.1cm}{\tikz[scale=.25] {
\draw [red,double] (1,0) -- (0,1) ;
\draw [blue,double, ] (0,0) -- (1,1) ;
}}r}$
% }
如果我取消注释这些行,从而将它们放入(子)部分,则会出现错误。
\documentclass[a4paper,10pt]{amsart}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
%openin
\begin{document}
\section{
Whatever description for $F_{q
\raisebox{-.1cm}{\tikz[scale=.25] {
\draw [red,double] (1,0) -- (0,1) ;
\draw [blue,double, ] (0,0) -- (1,1) ;
\draw [violet,double] (2,0) -- (1,1) ;
\draw [green,double, ] (1,0) -- (2,1) ;
}}r}$
}
\subsection{
Whatever description for $F_{q
\raisebox{-.1cm}{\tikz[scale=.25] {
\draw [red,double] (1,0) -- (0,1) ;
\draw [blue,double, ] (0,0) -- (1,1) ;
}}r}$
}
\end{document}
如何正确输入它们,以便它们可以出现在标题(和目录中)。后者似乎是问题所在:
\@writefile{toc}{\contentsline {section}{\tocsection {}{1}{ Whatever description for $F_{q \unhbox \voidb@x \let \reserved@d =[\def \par }$ }}{1}}
答案1
定义一个生成图片的命令,并在标题、说明等中将其置于前面\protect
。后一个命令负责确保受保护的命令不会过早展开。
\newcommand\xyz{...}
...
\section{... \protect\xyz ...}
\documentclass{article}
\usepackage{tikz}
\newcommand\qrbvgr
{q
\raisebox{-.1cm}{\tikz[scale=.25] {
\draw [red,double] (1,0) -- (0,1) ;
\draw [blue,double, ] (0,0) -- (1,1) ;
\draw [violet,double] (2,0) -- (1,1) ;
\draw [green,double, ] (1,0) -- (2,1) ;
}}r}
\newcommand\qrbr
{q
\raisebox{-.1cm}{\tikz[scale=.25] {
\draw [red,double] (1,0) -- (0,1) ;
\draw [blue,double, ] (0,0) -- (1,1) ;
}}r}
\begin{document}
\tableofcontents
\section{
Whatever description for $F_{\protect\qrbvgr}$
}
\subsection{
Whatever description for $F_{\protect\qrbr}$
}
\end{document}