1

I am designing a logo composed of two letters and am using the standalone class. I would expect the newer crop option to give me a "tighter" PDF output than the older preview option, but the reverse seems to be the case. Here is my MWE:

\documentclass[crop=true]{standalone}
\usepackage{fontspec}
\usepackage{xcolor}
\setmainfont{Noto Serif}
\setlength{\fboxrule}{0em}
\setlength{\fboxsep}{0em}
\begin{document}
\newbox{\Rx}
\newbox{\CRx}
\sbox{\Rx}{%
\fontsize{42pt}{50pt}\selectfont%
{R\hspace{-0.18em}{\raisebox{-0.22em}{\textcolor{gray}{x}}}}%
}
\fcolorbox{black}{lightgray}{\centering\usebox{\Rx}}
\end{document}

The result of the crop option is enter image description here

Whereas, if I replace the class option to be previewI get the tighter PDF whose screenshot is enter image description here

Why is there white space on the left of the crop image and how might it be avoided?

Thanks.

2
  • Both standalone options preview and crop are for cropping. The first one uses the preview package internal for that (which allows for paragraph content), the latter own code (which does not allow for paragraph content, and might swallow leading and trailing spaces). Feb 5, 2020 at 14:04
  • Thanks for the explanation @Martin Scharrer. The behaviour I have seen is now comprehensible.
    – chandra
    Feb 6, 2020 at 15:39

1 Answer 1

3

You have spurious spaces in your code:

\documentclass[crop=true]{standalone}
\usepackage{fontspec}
\usepackage{xcolor}
\setmainfont{Noto Serif}
\setlength{\fboxrule}{0em}
\setlength{\fboxsep}{0em}
\begin{document}
\newbox{\Rx}% <---
\newbox{\CRx}% <---
\sbox{\Rx}{%
\fontsize{42pt}{50pt}\selectfont%
{R\hspace{-0.18em}{\raisebox{-0.22em}{\textcolor{gray}{x}}}}%
}% <---
\fcolorbox{black}{lightgray}{\centering\usebox{\Rx}}
\end{document}
3
  • Thank you for pointing this out. I was hitherto unaware that a newline separating two one-line commands, or the newline at the terminus of a multi-line command, could both lead to a spurious space, and thus to unexpected results.
    – chandra
    Dec 31, 2019 at 16:21
  • Well you get a space if you type normal text on two lines, which should it be different if there are commands? Dec 31, 2019 at 16:25
  • I was not aware of that either. I tried out what you said and see that the newlines got translated into spaces in LaTeX. I need to pay more attention to terminal whitespace henceforth, including newlines.
    – chandra
    Dec 31, 2019 at 16:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .