6

Hi I am working on an appendix which has very large tables. Since I have these tables , I have narrowed the margins as much as possible so that they fit properly.

I am also using the showkeys package to cross-reference easily the appendix with the main article but since my margins are to narrow, I can't seem to print the complete label. I was wondering, is there a way to print the labels in vertical mode? Here is my minimal working example.

\documentclass[10pt]{article}
\usepackage{geometry}
\geometry{letterpaper}
\geometry{margin=1.5cm}
\usepackage{showkeys}
\usepackage{todonotes}

\begin{document}

\begin{figure}[H]
\caption{Example figure}
\begin{center}
\missingfigure[figwidth=0.7\textwidth]{Testing a long text string}
\end{center}
\label{add:label}
\end{figure}

\end{document}

This produces me an output like this:

enter image description here

You can see the label cropped at the left side. As you may see, this does not work for me. Is there any way to show the complete label without having to reduce the margins?

5

Using the url package with as many breaking options turned on as possible and making a fixed width box placed appropriately can help.

Sample output

\documentclass[10pt]{article}
\usepackage[verbose]{geometry}
\geometry{letterpaper}
\geometry{margin=1.5cm,marginparwidth=1.1cm,marginparsep=0.1cm}
\usepackage{showkeys}
\usepackage{todonotes}

\usepackage[obeyspaces,hyphens,spaces]{url}
\renewcommand*{\showkeyslabelformat}[1]{%
   \fbox{\vbox{\hsize=1.1cm\normalfont\small\url{#1}\par}}}

\begin{document}

\begin{figure}[H]
\caption{Example figure}
\begin{center}
\missingfigure[figwidth=0.7\textwidth]{Testing a long text string}
\end{center}
\label{add:label-long with space}
\end{figure}
\end{document}

If you need more break points in the labels then you can try passing such information to the url algorithm. Also making the label ragged-right can help with the spacing:

Second sample

\documentclass[10pt]{article}
\usepackage[verbose]{geometry}
\geometry{letterpaper}
\geometry{margin=1.5cm,marginparwidth=1.1cm,marginparsep=0.1cm}
\usepackage{showkeys}
\usepackage{todonotes}

\usepackage{ragged2e}
\usepackage[obeyspaces,hyphens,spaces]{url}
\renewcommand*{\showkeyslabelformat}[1]{%
  \expandafter\def\expandafter\UrlBreaks\expandafter{\UrlBreaks%  save the current one
  \do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j%
  \do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t%
  \do\u\do\v\do\w\do\x\do\y\do\z\do\A\do\B\do\C\do\D%
  \do\E\do\F\do\G\do\H\do\I\do\J\do\K\do\L\do\M\do\N%
  \do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X%
  \do\Y\do\Z}%
  \fbox{\vbox{\hsize=1cm\RaggedRight\noindent\normalfont\small\url{#1}\par}}}

\begin{document}

\begin{figure}
\caption{Example figure}
\begin{center}
\missingfigure[figwidth=0.7\textwidth]{Testing a long text string}
\end{center}
\label{add:label-long with space}
\end{figure}

\begin{equation}
  \label{eq:long-label-without-space}
  x=y.
\end{equation}
\end{document}
  • This would work if I could use spaces. However, my labels don't use spaces, I did not decide the label names and I am not authorized to change them :/ – MathUser Sep 12 '14 at 5:05
  • 1
    Further extension now provided - does this help? – Andrew Swann Sep 12 '14 at 20:03
  • @AndrewSwann, your extension turned out to be crucial to me. I also changed "small" to "tiny". Now displaying the labels in the margins in a draft is a viable option for me. – Jim Ratliff May 25 '18 at 22:56

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.