Short horizontal and vertical bar of same length in math
You need to take care of the current math style:
\documentclass{article}
\usepackage{amsmath,amssymb,graphicx}
\newcommand{\vrt}{\shortmid}
\makeatletter
\newcommand{\hrz}{{\mathpalette\hrz@\relax}}
\newcommand{\hrz@}[2]{%
\mspace{-1mu}%
\rotatebox[origin=c]{90}{$\m@th#1\,\vrt$}%
\mspace{-1mu}%
}
\makeatother
\begin{document}
$I^\hrz I^\vrt$
\end{document}
The reason why the rotated \shortmid
seems larger is because the default math size setting within \rotatebox
would be \textstyle
, while it should be \scripstyle
if you're using it in a superscript.
You could try with the following definitions of \vertical
and \horizontal
:
\documentclass{article}
\usepackage{amssymb,graphicx}
\newcommand{\horizontal}[1]{%
#1^{\rotatebox[origin=c]{90}{$\scriptstyle\shortmid$}}
}
\newcommand{\vertical}[1]{%
#1^{\shortmid}
}
\begin{document}
$\vertical{I}\ \horizontal{I}$
\end{document}
Preserves the proper math style.
\documentclass{article}
\usepackage{amssymb,graphicx,scalerel}
\newcommand{\vrt}{\shortmid}
\newcommand{\hrz}{{\ThisStyle{\rotatebox[origin=c]{90}{$\SavedStyle\vrt$}}}}
\begin{document}
$I^\hrz I^\vrt$
$\scriptstyle I^\hrz I^\vrt$
\end{document}