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
Asked
Active
Viewed 4,712 times
2 Answers
5
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}
Heiko Oberdiek
- 271,626
4
\stackinset allows you do do this with the syntax
\stackinset{H-anchor}{H-offset}{V-anchor}{V-offset}{inset}{base}
The inset and base can be glyphs, phrases, images, anything that can be set into a LaTeX box. The H-anchors are l, c, or r. The V-anchors are t, c, or b. You can stack math by default by issuing \stackMath, which is done for the 2nd example of the MWE, where I simulate an @ symbol by insetting a math a inside a math O.
\documentclass{article}
\usepackage{stackengine}
\begin{document}
\stackinset{c}{}{c}{}{\rule{.4pt}{2ex}}{C}
\stackMath
\stackinset{c}{}{b}{1pt}{a}{O}
\end{document}

The insets can be nested to inset multiple things over one base, such as in this answer: Mathematical formulas on a graph (not made by TeX)
Steven B. Segletes
- 237,551

\newcommand{\vertchar}[1]{\ooalign{#1\cr\hidewidth$|$\hidewidth}}with\vertchar{s}and\vertchar{c}(say), it doesn't really look nice with\vertchar{S}and\vertchar{C}. Could you be specific in terms of your actual usage? – Werner May 21 '14 at 18:34