2

I have some LaTeX code that uses the \resizebox command to make some hipster text, but the compiled letters are not completely flush to each side. There is a slight space on each side of the line as the font size changes, as shown in the screenshot.

I have tried to adjust this using the titlesec package but I'm a bit lost, as to how I would change this.

Has anyone got any ideas?

Here's my code too Edit: Current Code

\documentclass[a4paper]{article}
\usepackage{graphicx,showframe}

\setlength{\parindent}{0mm}
\setlength{\parskip}{1mm}

\begin{document}
\resizebox{1\hsize}{!}{LINE ONE OF TEXT}

\resizebox{1\hsize}{!}{LINE 2 IS A BIT SMALLER}

\resizebox{1\hsize}{!}{LINE THREE IS REALLY SMALL}

\resizebox{1\hsize}{!}{THIS LINE IS IN ITALLICS}

\resizebox{1\hsize}{!}{A LINE!}

\resizebox{1\hsize}{!}{I CAN JUST KEEP GOING}

\resizebox{1\hsize}{!}{AND GOING AND}

\resizebox{1\hsize}{!}{GOING}
\end{document}

Screen Shot

7
  • What PDF viewer are you using (Adobe doesn't show that selection discrepancy). – Werner Oct 9 '14 at 23:24
  • The letter G is quite narrower than its bounding box, which explains the last line; the same for the exclamation mark. Rather than using \part you should set \parindent to zero and \par after each box. – egreg Oct 9 '14 at 23:34
  • I would just use this code - it's easier to interpret. Maybe not the setting of \parskip, but it's just a suggestion. – Werner Oct 9 '14 at 23:44
  • Thank you for all your suggestions, they both help to clean up the code and improve the readability. But I'm still concerned that the exclamation mark ! is not flush with the right side. Anyone know how to fix this? Cheers again – Ben Winding Oct 9 '14 at 23:51
  • @TylerDurden: It actually is flush according to LaTeX as it uses the bounding box in order to adjust content. And, since the bounding box is different than the actual output, it is what it is... – Werner Oct 10 '14 at 0:04
2

You could use some trimming from adjustbox to compensate for the reduced bounding box of certain letters - a font-specific attribute:

enter image description here

\documentclass{article}
\usepackage[export]{adjustbox}
\usepackage{showframe}

\setlength{\parindent}{0mm}
\setlength{\parskip}{1mm}

\begin{document}

\resizebox{\linewidth}{!}{LINE ONE OF TEXT}%

\adjustbox{width=\linewidth,trim=0.1ex 0pt}{LINE ONE OF TEXT}%

\resizebox{\linewidth}{!}{A LINE!}%

\adjustbox{width=\linewidth,trim=0.08ex 0pt 0.2ex 0pt}{A LINE!}%

\end{document}

The visual alignment can be made as perfect as you want it, although the selection from within the PDF viewer may also be influenced by the trimming.

For a visual discussion on bounding boxes, see Standalone producing cropped / truncated formulae.

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.