首页 > 解决方案 > LaTeX \usepackage{forest} 不工作,显然是由于 .sty 文件?

问题描述

我正在尝试使用 TeX 包森林来绘制一个简单的树形图。但是,由于某种原因不想使用该软件包。我尝试从两个不同的镜像安装,并从 CTAN 网站手动安装,但仍然无法正常工作。导致错误的行是\usepackage{forest},因为没有此行文件编译得很好。根据下面的日志,错误出在forest.sty文件本身,但是似乎没有其他人遇到这个问题 - 除非它是由于新的 TeX 更新?

有人知道这里发生了什么吗?

! Missing \endcsname inserted.
<to be read again>
\unhbox
l.1061 }
The control sequence marked <to be read again> should
not appear between \csname and \endcsname.
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.1061 }
You're in trouble here. Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.
! Extra \endcsname.
\pgf@arrow@letter@ ...l@arrow@name@end \endcsname
#1
l.1061 }
I'm ignoring this, since I wasn't doing a \csname.
...
! Missing \endcsname inserted.
<to be read again>
\unhbox
l.1087 \csdef{forestmath@convert@from@n@to@_}
#1{\unexpanded{#1}}
The control sequence marked <to be read again> should
not appear between \csname and \endcsname.
! Missing \endcsname inserted.
<to be read again>
\unhbox
l.1088 \csdef{forestmath@convert@from@d@to@_}
#1{\unexpanded{#1}}
The control sequence marked <to be read again> should
not appear between \csname and \endcsname.
...

这持续了一段时间,从 1061 到 6309 行。错误列表显示了许多与此类似的行:

C:\...tex/latex/forest/forest.sty | Error line 1087 !Missing \endcsname inserted. <to be read again>\unhbox ...

forest.sty1086-8 行的文件是

1086: \def\forestmathzero{\forestmath@convert@from\forestmathtype@count{0}}
1087: \csdef{forestmath@convert@from@n@to@_}#1{\unexpanded{#1}}
1088: \csdef{forestmath@convert@from@d@to@_}#1{\unexpanded{#1}}

编辑:如下面的回答,问题出在 package underscore,即 line \usepackage[strings]{underscore}。因此,一个最小的例子是

\documentclass[a4paper]{article}
\usepackage[strings]{underscore}
\usepackage{forest}

\begin{document}
This won't work
\end{document}

标签: packagelatexpdflatexmiktex

解决方案


原来冲突的包是underscore,即行\usepackage[strings]{underscore}。删除此行可以解决问题。


推荐阅读