texjporg / platex

pLaTeX community edition
BSD 3-Clause "New" or "Revised" License
49 stars 8 forks source link

数式モード内の \ref でエラー #55

Closed aminophen closed 6 years ago

aminophen commented 6 years ago

31 の「\ref とスペースファクター」の修正に伴い,forum:2294#p13462 の現象が発生しています。

You can't use `\spacefactor' in math mode.

\documentclass[uplatex,dvipdfmx]{jsarticle}
\begin{document}
\section{A}\label{A}

\section{B}
$\ref{A}$
\end{document}
aminophen commented 6 years ago

一つの修正案としては,以下のようにすることでしょうか。

\@setref@ というマクロ名はテキトーです。目次で数式モードに入る場合も考慮すると,\protect しないといけないはずなので,こんな方法をとっています。

\def\@setref#1#2#3{%
  \ifx#1\relax
    \protect\G@refundefinedtrue
    \nfss@text{\reset@font\bfseries ??}%
    \@latex@warning{Reference `#3' on page \thepage \space
              undefined}%
  \else
    \expandafter#2#1\protect\@setref@{}% change \null to \protect\@setref@{}
  \fi}
\def\@setref@{\ifmmode\else\spacefactor\@m\fi}
aminophen commented 6 years ago

2017-11-03 付けでリリースしました。