我对乳胶还很陌生,所以请温柔一点。
我cancel
使用以下命令安装:
tlmgr install cancel
然后我创建了一个名为的测试文件,test.tex
其内容如下:
\documentclass[12pt]{article}
\usepackage{cancel}
\begin{document}
\cancel{test}
\end{document}
当我运行时pdflatex test.tex
,我得到以下输出:
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2015/01/01>
Babel <3.9l> and hyphenation patterns for 2 languages loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo))
(/home/quant/texmf/tex/latex/cancel/cancel.sty)
No file test.aux.
! You can't use `\/' in vertical mode.
\@cancel ...ht \unitlength \p@ \canc@thinlines {\/
\raise \dimen@ \hbox {\ooa...
l.5 \cancel{test}
但是,当我\cancel{test}
用类似 的内容替换时some text \cancel{test}
,编译成功。我怎样才能让它在行首删除内容的情况下进行编译?
答案1
我认为这是一个小错误。 readscancel
的定义\cancel
\DeclareRobustCommand\cancel[1]{\ifmmode
\mathpalette{\@cancel{\@can@slash{}}}{#1}\else
\@cancel{\@can@slash{}}\hbox{#1}\fi}
但它应该是
\DeclareRobustCommand\cancel[1]{\ifmmode
\mathpalette{\@cancel{\@can@slash{}}}{#1}\else
\leavevmode\@cancel{\@can@slash{}}\hbox{#1}\fi}
问题是,当\@cancel
它结束工作时,它会发出\hbox
打印结果的命令,但\hbox
不会启动段落模式。\leavevmode
这个问题可以避免。
你可以\mbox{}\cancel{test}
在被取消的单词开始一个段落时使用或者修补错误的命令:
\documentclass[12pt]{article}
\usepackage{cancel,xpatch}
\makeatletter
\xpatchcmd{\cancel}{\else\@cancel}{\else\leavevmode\@cancel}{}{}
\makeatother
\begin{document}
\cancel{test}
\end{document}
\xpatchcmd
您可以完整地陈述修复定义,而不是使用补丁:
\documentclass[12pt]{article}
\usepackage{cancel}
\makeatletter
\DeclareRobustCommand\cancel[1]{\ifmmode
\mathpalette{\@cancel{\@can@slash{}}}{#1}\else
\leavevmode\@cancel{\@can@slash{}}\hbox{#1}\fi}
\makeatother
\begin{document}
\cancel{test}
\end{document}