How to position letters *exactly* above each other?

TeX does not know the shape of the glyphs. It only knows the character box dimensions as specified in the TFM file.

Font identification

The font files can be identified the following way:

  • Use a document with just this font, for example, the document of the question is fine, if \pagestyle{empty} is added.

  • Run it through pdflatex with option -recorder.

  • The end part of the log file and the *.fls file reveals cmbx12.pfb as the font.

  • The font metrics can only be seen in the recorder file *.fls:

    INPUT cmbx12.tfm
    

Font shape data

Open the glyph shapes in a font editor like FontForge. The trim margins:

C: 62 -12 63 -12 (width 812)
E: 38   0 32   5 (width 738)

The font also tells that 1em = 1000 units

TeX metrics

The binary *.tfm file can be converted to ASCII in a better readable format by the program tftopl:

tftopl cmbx12.pfb cmbx12.pl

It contains at the beginning the font dimension parameters:

(FONTDIMEN
   (SLANT R 0.0)
   (SPACE R 0.375)
   (STRETCH R 0.1875)
   (SHRINK R 0.125)
   (XHEIGHT R 0.444444)
   (QUAD R 1.125)
   (EXTRASPACE R 0.125)
   )

The entry QUAD specifies the size of 1em. It is 1.125 of the font em size.

The character metrics are quite the same as in the font (except for some kind of "rounding" issues):

(CHARACTER C C
   (CHARWD R 0.8125)
   (CHARHT R 0.686111)
   )
...
(CHARACTER C E
   (CHARWD R 0.738426)
   (CHARHT R 0.686111)
   )

The width for C is 0.8125 * multiplied with the em size of the font = 812.5 font units. Truncated to integer, this are the 812 that FontForge has shown.

The following example defines some macros to specifiy the trim values for the glyph and defines macro \GlyphBox that fixes its TeX box to fit the glyph exactly (except rounding issues).

To keep the macros only work for one font. They can be extended to add another argument for the font name.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\makeatletter

\newcommand*{\EmSize}[1]{%
  \def\@EmSize{#1}%
}
\newcommand*{\@GlyphPropName}[2]{%
  GS@#1@#2%
}
\newcommand*{\GlyphProp}[2]{%
  \@nameuse{\@GlyphPropName{#1}{#2}}%
}
\newcommand*{\GlyphSize}[5]{%
  \@namedef{\@GlyphPropName{#1}{llx}}{#2}%
  \@namedef{\@GlyphPropName{#1}{lly}}{#3}%
  \@namedef{\@GlyphPropName{#1}{urx}}{#4}%
  \@namedef{\@GlyphPropName{#1}{ury}}{#5}%
}
\newcommand*{\GlyphBox}[1]{%
  \begingroup
    \leavevmode
    \setbox0=\hbox{#1}%
    \setbox0=\hbox{%
      \kern-\dimexpr1em*\GlyphProp{#1}{llx}/\@EmSize\relax
      #1%
      \kern-\dimexpr1em*\GlyphProp{#1}{urx}/\@EmSize\relax
    }%
    \ht0=\dimexpr\ht0 - 1em*\GlyphProp{#1}{ury}/\@EmSize\relax
    \dp0=\dimexpr\dp0 - 1em*\GlyphProp{#1}{lly}/\@EmSize\relax
    \box0\relax
  \endgroup
}
\makeatother
% Font cmbx12
\EmSize{1125}% 1000 units in font, 1.125 in TFM
\GlyphSize{C}{62}{-12}{63}{-12}
\GlyphSize{E}{38}{0}{32}{5}

\begin{document} 
\Huge
\bfseries

\setlength{\fboxsep}{0pt}
\setlength{\fboxrule}{.2pt}
\textcolor{red}{%
  \fbox{\color{black}\GlyphBox{C}}%
  \fbox{\color{black}\GlyphBox{E}}%
}

\begin{tikzpicture}[mytext/.style = {inner sep=0, outer sep=0}, font=\bfseries]
  \node (c1) [mytext, anchor=south] at (0,0) {\GlyphBox{C}};
  \node (c2) [mytext, above=0 of c1, color=red] {\GlyphBox{C}};
  \node      [mytext, above=0 of c2] {\GlyphBox{E}};
  \node (c3) [mytext, yscale=2, anchor=south] at (1,0) {\GlyphBox{C}};
  \node (c4) [mytext, yscale=0.5, above=0 of c3, color=red] {\GlyphBox{C}};
  \node      [mytext, yscale=0.5, above=0 of c4] {\GlyphBox{E}};
\end{tikzpicture}
\end{document}

Result


xelatex

enter image description here

pdflatex

enter image description here

15 more characters


I don't think you need a hammersledge like tikz for this: a simple tabular, the \scalebox command and the \Gape command from makecell for a precise adjustment, will do the job:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{xcolor}
\usepackage{makecell, graphicx}

\newcommand{\vscalebox}[2][1]{\scalebox{1}[#1]{#2}}

\begin{document}

\centering
\renewcommand{\arraystretch}{0}
\begin{tabular}{>{\bfseries\Huge}c}
E\\ \Gape[0.3pt]{\color{red}C}\\ \Gape[0.3pt]{C}
\end{tabular}
\quad
\begin{tabular}{>{\bfseries\Huge}c}
\vscalebox[0.5]{E}\\ \Gape[0.15pt]{\vscalebox[0.5]{\color{red}C}}\\ \Gape[0.6pt]{\vscalebox[2]{C}}
\end{tabular}

\end{document} 

enter image description here