我正在使用来自的 Tikz 代码package-lineno-not-working-well-skips-line-texlive-2016一切进展顺利。
当我verbatim
在最后添加一些文本时,现在我收到此错误lualtex
Package microtype Warning: Unknown slot number of character
(microtype) `\textgreater '
(microtype) in font encoding `TU' in protrusion list
(microtype) `T1-default'.
! Package tikz Error: Sorry, some package has redefined the meaning of the math
-mode dollar sign. This is incompatible with tikz and its calc library and migh
t cause unrecoverable errors.
See the tikz package documentation for explanation.
Type H <return> for immediate help.
...
我花了很多时间尝试制作 MWE。但它似乎是随机的。如果我缩小代码,或者移动verbatim
到文件顶部,错误就会消失。如果我删除geometry
包,错误就会消失。我甚至在随机位置删除了一个空白行,错误就消失了。
我在看 逐字写入某些文本时出现 package-tikz 错误并点击链接至半逐字记录 - 使用 tikz 在投影仪中并尝试了那里给出的修复但并没有消除错误:
所以我不知道现在该怎么做。我想保留显示行号的 tikz 代码。但我还想添加verbatim
。我可以显示的最小 Latex 文件有 150 行长。这会导致错误。我可以发布文件链接吗,因为它很长?或者我也可以粘贴在这里?几分钟后就可以了……
我在 Linux mint 上使用 TexLive 2016。在 Windows 上使用 Miktex 9。两者都出现相同的错误。
日志文件的结尾是:
Package tikz Error: Sorry, some package has redefined the meaning of the math
-mode dollar sign. This is incompatible with tikz and its calc library and migh
t cause unrecoverable errors.
See the tikz package documentation for explanation.
Type H <return> for immediate help.
...
l.26 \end{verbatim}
Here is how much of LuaTeX's memory you used:
12117 strings out of 494611
100000,319454 words of node,token memory allocated 2441 words of node memory still in use:
15 hlist, 1 vlist, 3 rule, 4 local_par, 4 dir, 101 glue, 8 kern, 44 penalty,
150 glyph, 25 attribute, 48 glue_spec, 25 attribute_list, 4 temp, 4 if_stack, 1
write, 5 pdf_literal, 3 pdf_colorstack nodes
avail lists: 2:6,3:1,4:1,8:1,9:1
15679 multiletter control sequences out of 65536+600000
17 fonts using 981063 bytes
55i,3n,54p,401b,458s stack positions out of 5000i,500n,10000p,90000000b,100000s
warning (pdf backend): no pages of output.
PDF statistics: 3 PDF objects out of 1000 (max. 8388607)
0 named destinations out of 1000 (max. 131072)
1 words of extra memory for PDF output out of 10000 (max. 10000000)
清单
感谢 TorbjørnT 在聊天中的帮助,他能够制作出更小的 MWE 来显示错误。这里是
\documentclass[12pt,letterpaper]{article}%
\usepackage[margin=1.1in]{geometry}
\usepackage{tikz,everypage}
\AtBeginDocument{%
\AddEverypageHook{%
\small
\begin{tikzpicture}[remember picture,overlay]
\path (current page.north west) -- (current page.south west)
\foreach \i in {1,...,\fakelinenos}
{ node [pos={(\i-.5)/\fakelinenos},
xshift=\fakelinenoshift, line number style] {\i} } ;
\end{tikzpicture}%
}%
}
\tikzset{%
line numbers/.store in=\fakelinenos,
line numbers=72,
line number shift/.store in=\fakelinenoshift,
line number shift=5mm,
line number style/.style={text=gray},
}
\begin{document}
\vspace*{20cm}
\begin{verbatim}
data1 = makeTable[0.01, 0, 2, 0];
At one second, using h=0.01 speed is 16.078 at step n = 100
At 2 seconds, using h=0.01 speed is 19.206 at step n = 200
data2 = makeTable[0.005, 0, 2, 0];
At one second, using h=0.005 speed is 16.02 at step n = 200
At 2 seconds, using h=0.005 speed is 19.195 at step n = 400
\end{verbatim}
\end{document}
答案1
在聊天中你说你正在使用 lualatex。在这种情况下,你可以重置 catcode 表:
\documentclass[12pt,letterpaper]{article}%
\usepackage[margin=1.1in]{geometry}
\usepackage{tikz,everypage}
\makeatletter
\AtBeginDocument{%
\AddEverypageHook{%
\small
\catcodetable \catcodetable@latex
\begin{tikzpicture}[remember picture,overlay]
\path (current page.north west) -- (current page.south west)
\foreach \i in {1,...,\fakelinenos}
{ node [pos={(\i-.5)/\fakelinenos},
xshift=\fakelinenoshift, line number style] {\i} } ;
\end{tikzpicture}%
}%
}
\makeatother
\tikzset{%
line numbers/.store in=\fakelinenos,
line numbers=72,
line number shift/.store in=\fakelinenoshift,
line number shift=5mm,
line number style/.style={text=gray},
}
\begin{document}
\vspace*{20cm}
\begin{verbatim}
data1 = makeTable[0.01, 0, 2, 0];
At one second, using h=0.01 speed is 16.078 at step n = 100
At 2 seconds, using h=0.01 speed is 19.206 at step n = 200
data2 = makeTable[0.005, 0, 2, 0];
At one second, using h=0.005 speed is 16.02 at step n = 200
At 2 seconds, using h=0.005 speed is 19.195 at step n = 400
\end{verbatim}
\end{document}
答案2
只需避免逐字逐句地运行 tikz,我也从上一个问题中复制了所需的 tikz 设置。
\documentclass[12pt,letterpaper]{article}%
\usepackage[margin=1.1in]{geometry}
\usepackage{tikz,everypage}
\newsavebox\mybox
\tikzset{%
line numbers/.store in=\fakelinenos,
line numbers=45,
line number shift/.store in=\fakelinenoshift,
line number shift=0mm,
line number style/.style={text=gray},
}
\savebox\mybox{\small
\begin{tikzpicture}
\path (current page.north west) -- (current page.south west)
\foreach \i in {1,...,\fakelinenos}
{ node [pos={(\i-.5)/\fakelinenos},
xshift=\fakelinenoshift, line number style] {\i} } ;
\end{tikzpicture}}
\AtBeginDocument{\AddEverypageHook{%
\llap{\smash{\raisebox{\dimexpr-\textheight-80pt}{\usebox{\mybox}}}}}}
\begin{document}
\vspace*{20cm}
\begin{verbatim}
data1 = makeTable[0.01, 0, 2, 0];
At one second, using h=0.01 speed is 16.078 at step n = 100
At 2 seconds, using h=0.01 speed is 19.206 at step n = 200
data2 = makeTable[0.005, 0, 2, 0];
At one second, using h=0.005 speed is 16.02 at step n = 200
At 2 seconds, using h=0.005 speed is 19.195 at step n = 400
\end{verbatim}
\end{document}
答案3
当我有一个跨页面的逐字块,并且我在文档的页脚中有一个 tikz 函数时,我遇到了这个问题。因此,tikz 代码实际上是在逐字部分中运行的,因为页脚是在逐字块期间开始新页面时呈现的。