![为什么 leftidx 在图标题中不起作用?](https://linux22.com/image/271357/%E4%B8%BA%E4%BB%80%E4%B9%88%20leftidx%20%E5%9C%A8%E5%9B%BE%E6%A0%87%E9%A2%98%E4%B8%AD%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8%EF%BC%9F.png)
我使用 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
。