# Single character ellipsis in monospace (teletype)

I would like to get an ellipsis as a single (width) character in \texttt. By default it uses three periods:

\documentclass{article}
\begin{document}
\centering
\begin{tabular}{rcc}
& ellipsis & three periods\\
plain & \textellipsis & ...\\
teletype & \texttt{\textellipsis} & \texttt{...}
\end{tabular}
\end{document}


I assume that the current behavior means I should not consider teletype (\texttt) as monospace, but as what one would do on a typewriter?

You can define your own single-character-width ellipsis:

\documentclass{article}
\newcommand\monoellipsis{\hbox to.5em{\hss.\hss\hss.\hss\hss.\hss}}
\begin{document}
\centering
\begin{tabular}{rcc}
& ellipsis & three periods & monoellipsis\\
plain & \textellipsis & ... & \monoellipsis\\
teletype & \texttt{\textellipsis} & \texttt{...} & \texttt{\monoellipsis}
\end{tabular}
\end{document}


You can add a test for a monospaced font based on comparing the width of i and m in the current font. I use 0.5em because this is the usual width of glyphs in monospaced fonts. You might want to be on the safe side and use

\fontcharwd\fontx


instead of 0.5em and 0.33333\fontcharwd\fontx instead of 0.16667em.

\documentclass{article}

\let\kerneltextellipsis\textellipsis
\newcommand{\textmonoellipsis}{%
\makebox[0.5em]{%
\makebox[0.16667em]{.}\hfil
\makebox[0.16667em]{.}\hfil
\makebox[0.16667em]{.}%
}%
}
\DeclareRobustCommand\textellipsis{%
\ifdim\fontcharwd\fonti=\fontcharwd\fontm
% i and m have equal width: monospaced font
\textmonoellipsis
\else
\kerneltextellipsis
\fi
}

\begin{document}

Normal text\dots

\texttt{Mono text\dots xyz}

\texttt{Mono textXxyz}

\end{document}


• Is \dots the same as \textellipsis in text mode? – equaeghe Apr 15 '18 at 21:00
• @equaeghe Yes: \dots actually does \ifmmode\mathellipsis\else\textellipsis\fi – egreg Apr 15 '18 at 21:03