1

I came across this question about the instances wherein non-breaking space should be used.

For cross-referencing, I am using cleveref. Although its documentation does not indicate anything about non-breaking spaces explicitly, it seems obvious that with cleveref, I no longer need a tie preceding the command \cref{}. Am I right?

I am asking this because, the linters chktex and lacheck integrated with my editor had warned me to introduce a tie. Now, after nearly finishing up the thesis (with the non-breaking spaces) and revisiting the question, it seems to me that this is unnecessary. Also, removal of the non-breaking space will lead to a non-negligible difference in pagination.

What is the general consensus on using non-breaking spaces with cleveref? It does seem to be unnecessary, and might even have placed unnecessary restrictions on the spacing for the box-glue-penalty model. If I have to remove it, is there a quick regex I can run from the command-line?

An obligatory MWE

\documentclass{article}
\usepackage{hyperref}
\usepackage{cleveref}
\begin{document}
See~\cref{sec:massenergy} for more details.

\section{Mass-Energy Relationship}\label{sec:massenergy}
According to blah blah ....

\end{document}

enter image description here

  • Please provide code to demonstrate the issue. – Steven B. Segletes Aug 21 '18 at 13:51
  • @StevenB.Segletes that seems like a template comment without even reading at what was asked. I am asking a conceptual question whether a need exists to use a non-breaking space preceding the \cref{} macro in any old document. If I have used it, will it hurt? – Krishna Aug 21 '18 at 13:53
  • 1
    Not all of use use cleveref, and yet some of us can solve issues with packages we don't regularly use. Without code, you limit your pool of available help to those who already know cleveref – Steven B. Segletes Aug 21 '18 at 13:54
  • OK. In this case, that is exactly what is needed. A consensus from those who use cleveref in their workflow. – Krishna Aug 21 '18 at 13:55
  • 1
    Seeing that \cref inserts not just a 1 but a Section 1, I would agree that no non-breaking space is needed before it. While one would not want a linebreak between "Section" and "1", I see no readability issue whatsoever with a linebreak before "Section." – Steven B. Segletes Aug 21 '18 at 14:02
4

The idea of placing a non-breaking space before, let's say, a \ref is that you wouldn't want the phrase Section 1 to be broken across 2 lines. With cleveref, however, the \cref provides not just the number, but also the preceding word. Thus, the need to apply a prior non-breaking space is alleviated.

For example, in the OP's case, Using See~\cref{...} prevents a linebreak between "See" and "Section", which not only is not necessary, but as we see in the MWE below, actually prevents proper margination by reducing the number of available breakpoints.

In the 1st line, a non-breaking space is used before the \cref and in the 2nd line, it is not.

\documentclass{article}
\usepackage[showframe,pass]{geometry}
\usepackage{hyperref}
\usepackage{cleveref}
\begin{document}
.\hspace{4.35in minus .1in}See~\cref{sec:massenergy} for more details.

.\hspace{4.35in minus .1in}See \cref{sec:massenergy} for more details.

\section{Mass-Energy Relationship}\label{sec:massenergy}
According to blah blah ....

\end{document}

enter image description here

For a source code that already is coded with such non-breaking spaces, I would recommend using an editor to globally replace instances of ~\cref with \ \cref.

1

Short answer: No, you don’t need to type ~ when using \cref.

Note that the tie ~ is needed between label names (such as section, figure, theorem) and label numbers. The tie ~ is not needed between See and section in your given example.

A quote from the cleveref documentation gives us some hint that the package uses ~ automatically:

Page 13: … \crefrange{thm1}{thm2} is typeset as

theorems~\ref{thm1}\crefrangeconjunction\ref{thm2}

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.