7

I'm doing a practical job and I need to place the glyphs of some typographies inside the box that contains them. I do not mean a box in common, but the box that contains the glyph and allows you to see its position inside the box. There is some direct function to obtain it or it is necessary to use other tools.

  • Depending on the precision you need, \fbox{<stuff>} does the job. You can use \setlength\fboxsep{0pt} prior to that to tighten the box around <stuff>. – Phelype Oleinik Oct 2 '18 at 13:55
  • You could also look at this: tex.stackexchange.com/questions/303483/… (answered by @egreg too, BTW). – Rmano Oct 2 '18 at 17:43
10

Here's a way, that also shows the baseline:

\documentclass{article}

\newlength{\glyphwd}
\newcommand{\showglyph}[1]{%
  \begingroup
  \settowidth\glyphwd{#1}%
  \setlength{\fboxrule}{0.1pt}% hairline
  \setlength{\fboxsep}{-0.05pt}%
  \makebox[0pt][l]{\vrule height 0.05pt depth 0.05pt width \glyphwd}%
  \fbox{#1}%
  \endgroup
}

\begin{document}

\showglyph{Q} \showglyph{\LARGE g} \showglyph{\LARGE\itshape f}

\end{document}

enter image description here

  • egreg, excellent, thank you very much. – Imago Mundi Oct 2 '18 at 15:47

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.