3

I am using Tikz code from package-lineno-not-working-well-skips-line-texlive-2016 and everything have been working very well.

When I added some verbatim text at the end, now I get this error from 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.
 ...                                              

I spend alot of time trying to make MWE. But it seems to be random. If I make the code smaller, or move verbatim to top of file, the error goes away. If I remove geometry package, error goes away. I even removed one blank line in random location, and error went away.

I looked at package-tikz-error-when-writing-some-text-in-verbatim and followed link to semiverbatim-with-tikz-in-beamer and tried the fix given there but that did not remove the error:

Mathematica graphics

So I am not sure what to do now. I'd like to keep the tikz code, which shows the line numbers. But I also want to add verbatim. The smallest Latex file I can show is 150 lines long. This causes the error. I can post a link to the file, since it is long? Or I can paste here also? Will do in few minutes...

I am using TexLive 2016, on Linux mint. On windows, using Miktex 9. Both give same error.

End of log file is:

 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)

Listing

Thanks to TorbjørnT help in chat, he was able to make even smaller MWE that shows the error. Here it is

\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
    you should be able to post a MWE the document is only 171 lines and you can shrink by replacing each equation by 1=2 and each (say) 5 line paragraph by a\\a\\a\\a\\a But I would guess you have tikz in the page head at the point verbatim is breaking over a page. – David Carlisle Feb 6 '17 at 10:04
  • 1
    The problem is obviously that LaTeX is trying to make the picture when it is in the middle of a verbatim environment. What should \fakelinenos and \fakelinenoshift mean? – egreg Feb 6 '17 at 10:37
  • 1
    Perhaps I removed too much, the \tikzset where \fakelinenos and \fakelinenoshift is defined might be good to have, even if the error itself is reproduced without it. – Torbjørn T. Feb 6 '17 at 11:13
  • 1
    @TorbjørnT. ok, I added \tikzset back. I saw you removed it, but I assumed you did not think it was needed. It is back into the code now. thanks. – Nasser Feb 6 '17 at 11:17
3

In the chat you said you are using lualatex. In this case you can reset the catcode table:

\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}
4

Just avoid running the tikz inside verbatim, also I copied your required tikz setup from the previous question.

\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}
  • How do you avoid to run the tikz inside verbatim? I don't get with your answer. – antoine Aug 21 '17 at 10:16
  • @antoine the tikz is run at the start of the document in a box and the box just copied each page, rather than executing the tikz each page – David Carlisle Aug 21 '17 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.