1

Consider the following

\documentclass[12pt]{report}
\usepackage[norefs]{refcheck}
\begin{document}
\label{beware}
\chapter{Troubleshooting \LaTeX: what to do when trouble shoots back}
See page~\pageref{beware}; if that doesn't help; run for cover! $\ddot\smile$
\end{document}

The chapter starts on page 2, instead of page 1; this doesn't happen without refcheck. This is not too annoying and I can easily work around it, because there are currently only two labels in the whole document that trigger this, and I don't need either one of them. Alternatively, a couple of blank pages is also not the end of the world. But still.

  • 1
    Try eliminating the space you currently have before \chapter by commenting the end of the preceding line. – cfr Apr 24 '16 at 2:49
  • 1
    It is adding a box, albeit an empty one. If I stop it doing that, it fails with a fatal error :(. – cfr Apr 24 '16 at 3:28
  • 1
    I tried \renewcommand{\label}[1]{\@bsphack\global\@labelledtrue \gdef\last@lbl{\@verbatim@{#1}}% \@ifundefined{lab@#1}{\global\@unsdlbltrue \@warning@rc@{Unused label `#1'}}% {\global\@unsdlblfalse}% \if@show@ref \ifmmode\relax\else {\setbox0=\vbox{\vss\@setnmmarginlbl}% \wd0=0pt\ht0=0pt\dp0=0pt% \ifvmode \@tempdima=\prevdepth \nointerlineskip\box0\nobreak \prevdepth=\@tempdima \else \vadjust{\box0\nobreak}% \fi}% \else\relax \fi \fi \@@label@@{#1}\@esphack} which just adds a conditional on show refs. – cfr Apr 24 '16 at 12:12
  • 1
    OK. I figured out it just needs to be delayed and not done in the preamble. Wrapping it in a \AtBeginDocument{...} avoids the fatal error. I had just tried putting it in the preamble, which didn't work, but experimented a bit in light of your report of its working OK for you. – cfr Apr 24 '16 at 20:37
  • 1
    I'm not sure what a \label in that position is supposed to do. – egreg Apr 24 '16 at 21:27
2

We can modify refcheck's redefinition of \label so that it only creates a box for the reference label if the option to show references is activated. The prevents it from creating an empty box with no content which is responsible for the blank page.

\makeatletter
\renewcommand{\label}[1]{\@bsphack\global\@labelledtrue
  \gdef\last@lbl{\@verbatim@{#1}}%
  \@ifundefined{lab@#1}{\global\@unsdlbltrue
  \@warning@rc@{Unused label `#1'}}%
  {\global\@unsdlblfalse}%
  \if@show@ref
    \ifmmode\relax\else
      {\setbox0=\vbox{\vss\@setnmmarginlbl}%
      \wd0=0pt\ht0=0pt\dp0=0pt%
      \ifvmode
        \@tempdima=\prevdepth
        \nointerlineskip\box0\nobreak
        \prevdepth=\@tempdima
      \else
        \vadjust{\box0\nobreak}%
      \fi}%
    \else\relax
    \fi
  \fi
  \@@label@@{#1}\@esphack}%
\makeatother

However, this cannot be done in the preamble else compilation fails with a fatal error. So, we wrap the redefinition in \AtBeginDocument{} to delay execution while keeping things tidy and avoiding the use of \makeatletter in the document environment.

\documentclass[12pt]{report}
\usepackage[norefs]{refcheck}
\makeatletter
\AtBeginDocument{%
  \renewcommand{\label}[1]{\@bsphack\global\@labelledtrue
    \gdef\last@lbl{\@verbatim@{#1}}%
    \@ifundefined{lab@#1}{\global\@unsdlbltrue
    \@warning@rc@{Unused label `#1'}}%
    {\global\@unsdlblfalse}%
    \if@show@ref
      \ifmmode\relax\else
        {\setbox0=\vbox{\vss\@setnmmarginlbl}%
        \wd0=0pt\ht0=0pt\dp0=0pt%
        \ifvmode
          \@tempdima=\prevdepth
          \nointerlineskip\box0\nobreak
          \prevdepth=\@tempdima
        \else
          \vadjust{\box0\nobreak}%
        \fi}%
      \else\relax
      \fi
    \fi
    \@@label@@{#1}\@esphack}%
}
\makeatother
\begin{document}
\label{beware}
\chapter{Troubleshooting \LaTeX: what to do when trouble shoots back}
See page~\pageref{beware}; if that doesn't help; run for cover! $\ddot\smile$
\end{document}

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.