# draw the container box of a glyph

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

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}


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