tikz 和 luatexja 的“\end 發生在 \ifnum ... 不完整時”

tikz 和 luatexja 的“\end 發生在 \ifnum ... 不完整時”

以下MCE:

\documentclass{article}
\usepackage{tikz}
% \usepackage{luatexja}
\begin{document}
\tikz{\coordinate[yshift=\the\ht\strutbox];}
\end{document}

編譯時沒有任何可疑之處,但是,如果luatexja載入包,則該.log文件包含(奇怪的是既沒有警告也沒有錯誤):

(\end occurred when \ifnum on line 25 was incomplete)
(\end occurred when \if on line 25 was incomplete)

誰是罪魁禍首:

  • 包裹luatexja
  • 程式碼tikz{\coordinate[yshift=\ht\strutbox];},其錯誤本質是由 揭示的luatexja

編輯

這是一個失敗的現實世界使用範例(摘錄)(真實文件包含對ProfCollegehanzibox套件的評論):

\documentclass{article}
\usepackage{ProfCollege}
\usepackage{luatexja}
\begin{document}
\Pourcentage[Calculer]{15}{39}

\verb+\hanzibox*[frametype=none]{我}[wo3][moi]\\[1ex]+
\end{document}

答案1

這是可行的,但你得到的長度是相當不可預測的,因為它取決於當前的文字方向。

\documentclass{article}
\usepackage{tikz}
\usepackage{luatexja}
\begin{document}

\tikz{\coordinate[yshift=\the\expandafter\ht\expanded{\strutbox}];}

\end{document}

當 僅僅是一個盒子寄存器名稱時它也可以工作\strutbox,因為它是不可擴展的,所以\expanded返回\strutbox

為了使其工作ProfCollege,您可以修補使用該結構的套件中的宏

\documentclass{article}
\usepackage{ProfCollege}
\usepackage{luatexja}
\usepackage{etoolbox}

% the abstract version of the above
\newcommand{\getstrut}[1]{%
  \the\expandafter#1\expanded{\strutbox}%
}
% the internal commands of ProfCollege to patch
\patchcmd{\TikzPH}{\the\dp\strutbox}{\getstrut\dp}{}{}
\patchcmd{\TikzPHD}{\the\dp\strutbox}{\getstrut\dp}{}{}
\patchcmd{\TikzPHD}{\the\dp\strutbox}{\getstrut\dp}{}{}
\patchcmd{\TikzPB}{\the\ht\strutbox}{\getstrut\ht}{}{}
\patchcmd{\TikzPBD}{\the\ht\strutbox}{\getstrut\ht}{}{}
\patchcmd{\TikzPBD}{\the\ht\strutbox}{\getstrut\ht}{}{}
\patchcmd{\TikzRH}{\the\ht\strutbox}{\getstrut\ht}{}{}
\patchcmd{\TikzRB}{\the\dp\strutbox}{\getstrut\dp}{}{}
% the user level command to patch
\patchcmd{\FlecheLineaireH}{\ht\strutbox}{\getstrut\ht}{}{}

\begin{document}

\Pourcentage[Calculer]{15}{39}

\verb+\hanzibox*[frametype=none]{我}[wo3][moi]\\[1ex]+

\begin{center}
\Propor[
  Stretch=1.25,
  Math,
  GrandeurA=Hauteur $h$ (cm),
  GrandeurB=\begin{tabular}{c}Volume (en cm$^3$) d'un cylindre\\ de rayon \Lg{5} et
            de hauteur $h$\end{tabular},
  Largeur=0.75cm
]{2/$50\pi$,3/$75\pi$,5/}
\end{center}
\FlecheLineaireH{1}{2}{3}{$+$}
\FlecheLineaireB{1}{2}{3}{$+$}

\end{document}

使用的唯一用戶級命令\ht\strutbox\FlecheLineaireH,很奇怪沒有\the,但我從包文檔中複製了示例,它似乎可以工作。

以前的警告仍然適用:如果您按照 允許的方式使用不同的文字方向luatexja,您會遇到麻煩。

在此輸入影像描述

相關內容