# Problem with package lineno

I'm using package lineno for proofreading of my documents. So I usually have something like the following MWE:

\documentclass{article}

\usepackage{blindtext}

\usepackage{ifthen}           % to use if then else
\setboolean{korrektur}{true} % choose one, comment the other
%\setboolean{korrektur}{false}

% What we need for proofreading
{% YES:
\usepackage{showframe}          % shows type area
\usepackage{lineno}             % numbers lines
\pagewiselinenumbers            % lines per page
}%
{% NO:
% error if lineno was used before:
\typeout{***** Please delete .aux files if you get errors! *****}
% What to add here so that I get no errors?  %<=================
}

\begin{document}
\Blindtext
\end{document}


Run it two times. Everything should be well, blindtext is numbered.

Now please move the % sign from line 8 (false) to line 7 (true).

Because we had had the run before there is an .aux-file, including lines with the macro \@LN.

If you compile now you will get the following error message (and some more):

***** Please delete .aux files if you get errors! *****
(C:\Users\...\LaTeX\_TeX.SX\lineno\test-lineno.aux
! Undefined control sequence.
l.2 \@LN
{0}{0}


Question: Is it possible to add in line 20 (see %<===========) something to get rid of the error messages? Something that resets the meaning of macro \@LN?

Note that the error involving \@LN reports the macro to possibly take 2 arguments. This is confirmed from within lineno.sty:

\def\@LN#1#2{{\expandafter\@@LN
\csname LN@P#2C\@LN@column\expandafter\endcsname
\csname LN@PO#2\endcsname
{#1}{#2}}}


\makeatletter
\providecommand{\@LN}[2]{}
\makeatother


at the "base level" in your preamble (for example, just after \documentclass{article}). This will define \@LN (the missing macro) only if it is not already defined. Since the package defines \@LN via \def, it will be redefined if lineno is loaded.

If you which to provide this command within another command (like within the false clause of your conditional), then you need to place the \makeatletter...\makeatother pair outside the main conditional:

\makeatletter
\ifthenelse{..}
{% YES:
%...
}{% NO:
%...
\providecommand{\@LN}[2]{}%
}
\makeatother