\language@active@arg< 的參數有額外的 }

\language@active@arg< 的參數有額外的 }

我有小MWE:

  \batchmode
  \documentclass[twoside]{book}
  \usepackage[spanish]{babel}
\begin{document}
\chapter{Referencia \texorpdfstring{$<$}{<} }
\end{document}

這會導致錯誤(使用 pdflatex):

! Argument of \language@active@arg> has an extra }.
<inserted text>
                \par
l.5 \chapter{Referencia \texorpdfstring{$<$}{<} }

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?
! Paragraph ended before \language@active@arg> was complete.
<to be read again>
                   \par
l.5 \chapter{Referencia \texorpdfstring{$<$}{<} }

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.
...

關於如何以一般方式解決這個問題有什麼建議嗎? (中的其他字元也會出現問題textorpdfstring

答案1

嗯...你把 MWE 降低太多了。你不應該hyperref也加載嗎?無論如何,<在西班牙語 babel 中預設處於活動狀態。我的解決方案(假設我無論如何都使用 unicode/utf8 編碼)是始終使用:

\documentclass[twoside]{book}
  \usepackage[T1]{fontenc}
  \usepackage[spanish, es-noshorthands, shorthands=off]{babel}
  \usepackage{hyperref}
\begin{document}
\chapter{Referencia \texorpdfstring{$<$}{<} }
\end{document}

這幾乎在任何地方都有效。

相關內容