我正在尝试将国际象棋 pdf 转换为 html 文件,然后再转换为 mobi 并将其与图表一起保存。我通过 TeXStudio 上的 tex4ht 执行此操作。我有代码:
\documentclass{article}
\usepackage{xskak}
\begin{document}
\newchessgame
\chessboard[setfen=r5k1/1b1p1ppp/p7/1p1Q4/2p1r3/PP4Pq/BBP2b1P/R4R1K w - - 0 20]
\end{document}
并得到错误:
! Undefined control sequence.
\@tempc ...>\def \@tempb {\@tempc }\sv:begingroup
\toks@ {#2}\edef \@tempa {...
l.5 \chessboard
[setfen=r5k1/1b1p1ppp/p7/1p1Q4/2p1r3/PP4Pq/BBP2b1P/R4R1K w - ...
有没有办法避免这种错误?
答案1
你可能有一个较旧的 TeX 发行版,因为你的系统上似乎缺少 Xskak 的 TeX4ht 配置文件。你可以尝试将其放入包含你的文件的目录中,命名为xskak.4ht
:
% xskak.4ht (2022-11-04-13:31), generated from tex4ht-4ht.tex
% Copyright 2022 TeX Users Group
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
\immediate\write-1{version 2022-11-04-13:31}
\ExplSyntaxOn
\def\:xskakdepth{vertical-align:-\fp_eval:n{
\dim_to_fp:n{\dp0}/(\dim_to_fp:n{\ht0}+\dim_to_fp:n{\dp0}) * 100
}\@percentchar;}
\ExplSyntaxOff
\NewConfigure{mainline}{2}
\def\:tempa#1{%
\setbox0=\hbox{\o:mainline:{#1}}%
\edef\:xskakalt{\detokenize{#1}}%
%\a:mainline\Picture*[\detokenize{#1}]{ style="\:xskakdepth"}\box0\EndPicture\b:mainline%
\a:mainline\box0\b:mainline%
}
\HLet\mainline\:tempa
\NewConfigure{xskakget}{2}
\def\:tempa#1{%
\edef\:xskakalt{\detokenize{#1}}%
\setbox0=\hbox{\o:xskakget:{#1}}%
\a:xskakget\box0\b:xskakget%
}
\HLet\xskakget\:tempa
\NewConfigure{chessboard}{2}
\def\:tempa{%
% reset to the original version of \chessboard
\let\:currchesboard\chessboard
\let\chessboard\o:chessboard:%
\o:newchessgame:%
% set the TeX4ht version of \chessboard back
\let\chessboard\:currchesboard
}
\HLet\newchessgame\:tempa
\Hinput{xskak}
\endinput
您仍有可能遇到由其他文件引起的错误。最好尝试将您的 TeX 发行版更新到 TeX Live 2023。
使用 TeX Live 2023 时,我收到另一个错误,可以使用此配置文件修复config.cfg
:
\Preamble{xhtml}
\catcode`\:=11
\makeatletter
\def\chessboard:alt{\ifdefined\o:xskakget:\ifcsname Xskak.\xskak@val@gameid.\xskak@val@movenr.\xskak@[email protected]\endcsname\o:xskakget:{nextfen}\fi\fi}
\makeatother
\catcode`\:=12
\begin{document}
\EndPreamble
您可以从命令行编译文件,使用:
$ make4ht -c config.cfg filename.tex
经过此更改后,文件应该可以顺利编译: