1

after compiling (2 times) a .tex file with:

latex "\AtBeginDocument{\RequirePackage[pagewise]{lineno}\linenumbers}\input{mydocument.tex}"

and than compiling again with

latex mydocument.tex

I get this error:

! Undefined control sequence.
l.3 \@LN

to remove which, I need to delete the .aux file and compiling again.

To avoid this I figured out to write and read a renamed .aux file for the line-numbering compiling. Is it possible to do that (by command line)? All suggestions are welcome.

You can try with:

\documentclass[11pt]{article}
\pdfoutput=1
\pagestyle{empty}

\usepackage{lipsum}

%% \usepackage[pagewise]{lineno}
%% \linenumbers
\begin{document}

\lipsum

\lipsum

\lipsum

\end{document}

P.S. How can I insert the compiled file (pdf or dvi) in this page?

EDIT: I figured out a possible solution: how if, after compiling, I put the definition of \@LN at the top (or at the right point) of the .aux file? My problem is I'm don't know how to find this definition. I looked at lineno.sty but I've not been been found it.

With simple latex command the compiler would non complaint about the undefined command and overwrite the aux file. With the lineno package the compiler would simply find a duplicate of the \@NL command definition in the .aux file.

Could it works?

  • 2
    to show the output take a (cropped) screenshot of your pdf viewer and upload a png image – David Carlisle Jun 28 '17 at 9:37
  • Why don't you just remove the aux file "from the command line" as part of the compilation process? Something like /bin/rm -f mydocument.aux && latex ... – Andrew Jun 28 '17 at 10:12
  • @Andrew Please, read my comment to egreg answer. – Gabriele Nicolardi Jun 28 '17 at 10:36
  • I don't understand you mean by "I do not want to modify the default emacs compiling setup" because with the latex "\AtBeginDocument... you are already doing this. This said, why not expand this line to latex "\AtBeginDocument{\RequirePackage[pagewise]{lineno}\linenumbers}\makeatletter\def\@LN#1#2{}\makeatother\input{mydocument.tex}" ? – Andrew Jun 28 '17 at 11:59
  • @Andrew Ok, I have a default compiling string (actually an emacs command) key-binded to Ctrl-cCtrl-f. I want to use the same key binding for a set of compiling styles. To do that I wrote a set of functions for these styles and a function to toggle the key-binding to these functions (once at time). I don't want to modify the default (internal) emacs function. I need a way to compile the .tex file with the default tex-file emacs function aftet compiling with the lineno's pagewise option. But it seems not possible. – Gabriele Nicolardi Jun 28 '17 at 12:16
2

Isn't it simpler to do the conditional in the document?

\documentclass[11pt]{article}

\usepackage{lipsum}

\newif\ifproof
%\prooftrue

\ifproof
  \usepackage[pagewise]{lineno}
  \linenumbers
\else
  \makeatletter
  \def\@LN#1#2{}
  \makeatother
\fi

\begin{document}

\lipsum

\lipsum

\lipsum

\end{document}

When \prooftrue is commented, no line numbers are added. Uncomment and you'll get them.

If you really need to do it from the command line, use

latex '\expandafter\providecommand\csname @LN\endcsname[2]{}\makeatother\input{mydocument.tex}'

for the case when you don't want line numbers.

  • Yes it is. But I need to do it by command line. Let me explain my project. I use emacs to format papers for scientific journals. In emacs I have a key binding (C-cC-f) to compile my files. I wrote a function to toggle the key binding behaviour to different kinds of compiling styles (draft, boxed figures... and page numbering). I don't want to modify the tex file. I hope I explained myself enough. – Gabriele Nicolardi Jun 28 '17 at 9:45
  • I really thank you for your effort, but you second solution does not fit yet my needs, because I do not want to modify the default emacs compiling setup (and I don't want to get mad with another option like that). What I really need is to let the linenumbers compiling option make the job. – Gabriele Nicolardi Jun 28 '17 at 10:41
  • @GabrieleNicolardi Well, then you're doomed. ;-) “Botte piena e moglie ubriaca…” – egreg Jun 28 '17 at 10:42
  • Really? So I will give up the pagewise option. (Without that ones all works fine). Thank you. – Gabriele Nicolardi Jun 28 '17 at 10:49
  • Dear Figaro, "...io son Lindoro, che fido v'adoro..." but I would have preferred "Ecco, ridente in cielo spunta la bella aurora...". No "aurora" this time. ;-) – Gabriele Nicolardi Jun 28 '17 at 11:03
1

You could define \@LN in the document preamble, though based not on whether lineno is loaded, but simply on whether the \@LN macro is defined. The following example illustrates the idea:

\documentclass[11pt]{article}
\pdfoutput=1
\pagestyle{empty}

\usepackage{lipsum}

%% \usepackage[pagewise]{lineno}
%% \linenumbers
\makeatletter
\ifx\@LN\undefined
  \def\@LN#1#2{}
\fi
\makeatother

\begin{document}

\lipsum

\lipsum

\lipsum

\end{document}
  • Thank you. But I really need to not modify the .tex file. I've just explained my needs in a comment to the egreg answer. – Gabriele Nicolardi Jun 28 '17 at 10:44
  • I'm afraid you'll have to modify something. Either your command line per suggestion by @egreg, or the document source. What's wrong with adding conditional to the preamble? – Sergei Golovan Jun 28 '17 at 10:49
  • The company I work for doesn't encourage that kind of solutions. Also a command line one will be cleaner and faster. Thank you. – Gabriele Nicolardi Jun 28 '17 at 10:53
  • May be you'd want to have an auxiliary document proofed.tex which would contain \AtBeginDocument{\RequirePackage[pagewise]{lineno}\linenumbers}\input{mydocument.tex}? After that you build either proofed.tex or mydocument.tex and have two PDFs, one with line numbers, the other without. The \@LNs will go to the proofed.aux and won't harm your main aux. – Sergei Golovan Jun 28 '17 at 11:03
  • It would be complicate to implement the autors' proofs. :-( – Gabriele Nicolardi Jun 28 '17 at 11:08

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.