[Tex/LaTex] Vertical line superimposed over a letter

symbols

Looking for a way to put a vertical line over another character. Similar to the \cancel feature, but with a vertical, rather than a slanted line. For example on a capital S the vertical line would turn it into something akin to a US dollar symbol: $. (verticallity in this text box seems dependent upon font choice)
i.e. superimpose a | over a C

Best Answer

The following solution uses TikZ (more configuration options as rounded line caps, ...). The optional argument of \vertchar allows horizontal fine tuning:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand*{\vertchar}[2][0pt]{%
  \tikz[
    inner sep=0pt,
    shorten >=-.15ex,
    shorten <=-.15ex,
    line cap=round,
    baseline=(c.base),
  ]\draw
    (0,0) node (c) {#2}
    ($(c.south)+(#1,0)$) -- ($(c.north)+(#1,0)$);%
}
\begin{document}
  \vertchar{S} and \vertchar{C} or \vertchar[.08ex]{C}
\end{document}

Result

Related Question