我使用 leftidx 包来获得可接受的左下标排版,但是,当我尝试在图形标题 (\caption) 命令中使用 \leftidx 命令时,编译时出现错误。以下是 MWE:
\documentclass[12pt,letterpaper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{leftidx}
\usepackage{mathrsfs}
\usepackage{bm}
\usepackage{graphicx}
\begin{document}
I want $\leftidx{^i}{c}{_{l,m}^{n}}$ in a caption.
\begin{figure}
\caption{$\leftidx{^i}{c}{_{l,m}^{n}}$}
%\caption{$2+2=4$}
\end{figure}
\end{document}
如果您用 \leftidx 注释掉 \caption 行,并取消注释其下方的行,您将看到它编译正常,包括对标题之外的 \leftidx 的调用。我在标题内使用 \leftidx 时遇到的错误是:
! Incomplete \iffalse; all text was ignored after line 17.
<inserted text>
\fi
<*> MWE.tex
The file ended while I was skipping conditional text.
This kind of error happens when you say `\if...' and forget
the matching `\fi'. I've inserted a `\fi'; this might work.
! Emergency stop.
<*> MWE.tex
*** (job aborted, no legal \end found)
答案1
您需要\protect
在 之前立即插入\leftidx
。