0

Is there a trick (I have seen no option for that) to switch on/off the printing of the keys? Switch off would be enough. Because at the end of my draft document I have toc's that help me in my work, and there the keys are more an obstacle then a help.

EDIT. Example added:

\documentclass{book}
\usepackage{showkeys} 
\usepackage{nameref}
\begin{document}
\chapter{ch1}\label{ch:first}
\section{Introduction}
First page
\section{Conclusion}\label{sec:aaa}
\addcontentsline{toc}{chapter}{sec of \nameref{ch:first}}

abc\label{abc}
\renewcommand*\showkeyslabelformat[1]{}
xyz\label{xyz}

\tableofcontents

\end{document}

In the table of contents there should be no reference from showkeys

  • As usual, add a compilable code example please, something we can work with. – AlexG Jul 9 '19 at 12:08
  • showkeys tries hard not to interfere with the pagination, but it's not guaranteed that line and page breaks will be as good as they could. The simplest way to turn off showkeys is to comment out the line \usepackage{showkeys}. – egreg Jul 9 '19 at 12:24
  • I've added an example – PeptideChain Jul 9 '19 at 14:35
2

As mentioned in the documentation, you can redefine the printing command. This will affect \label. \ref (and \nameref}) uses another command and there seem not to be an official interface. But redefining an internal command seems to work.

\documentclass{book}
\usepackage{showkeys}
\usepackage{nameref}
\begin{document}
\chapter{ch1}\label{ch:first}
\section{Introduction}
First page
\section{Conclusion}\label{sec:aaa}
\addcontentsline{toc}{chapter}{sec of \nameref{ch:first}}

abc\label{abc}
\ref{xyz} \nameref{ch:first}

\renewcommand*\showkeyslabelformat[1]{}
\makeatletter
\def\SK@@ref#1>#2\SK@{}
\makeatletter

xyz\label{xyz} 
\ref{xyz} \nameref{ch:first}

\tableofcontents

\end{document}

enter image description here

| improve this answer | |
  • wow a documented feature – David Carlisle Jul 9 '19 at 12:21
  • In a normal case it works, but in case of a table of contents/list, where the label have been defined earlier, it doesn't. I guess that the generation of the extra output is stopped, but not the printing of labels. – PeptideChain Jul 9 '19 at 13:06
  • You didn't provide any code so it wasn't possible to test your setup. – Ulrike Fischer Jul 9 '19 at 13:40
  • It was not a criticism, just an info for people looking for solutions. I've edited the question adding an example of the problem described. – PeptideChain Jul 9 '19 at 14:37
  • I added an edit for \ref and \nameref. – Ulrike Fischer Jul 9 '19 at 21:20

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.