[Tex/LaTex] How to use only one glyph from textcomp

fontssymbols

I'd like to use the symbol given by textordmasculine from the textcomp package.

But I don't want to load textcomp since it is too much and I only want that symbol (in fact I need the masculine order symbol with the underline and I didn't find this symbol except using textcomp).

From CTAN I found

\DeclareTextSymbol{\textordmasculine}{TS1}{'272}
\DeclareTextSymbolDefault{\textordmasculine}{TS1}

but have no idea how to use these lines to load that symbol.

If I use both I get

Encoding scheme `TS1' unknown. ...ontFamily{TS1}{cmr}{\hyphenchar\font\m@ne}
Encoding scheme `TS1' unknown. \DeclareFontFamily{TS1}{phv}{}

Best Answer

Full textcomp

\documentclass{article}
\usepackage{textcomp}   
\begin{document}
\textordmasculine
\end{document}

Package textcomp takes care of font families that do not support the full range of encoding TS1 by a concept of "subencoding".

Full encoding TS1 without textcomp

\documentclass{article}
\usepackage[TS1,OT1]{fontenc}% or T1 instead of OT1
\begin{document}
\textordmasculine
\end{document}

That assumes that the used font supports all symbols of TS1. However, \textordmasculine is usually not missing. But other symbols like \textbullet are redefined to use TS1 encoding.

Partial encoding TS1 with \textordmasculine

\documentclass{article}

\DeclareFontEncoding{TS1}{}{}
\DeclareFontSubstitution{TS1}{cmr}{m}{n}
\DeclareTextSymbol{\textordmasculine}{TS1}{186}
\DeclareTextSymbolDefault{\textordmasculine}{TS1}

\begin{document}
\textordmasculine
\end{document}

Then the symbol is still defined using LaTeX's NFSS2. That means font size commands, changing font attributes (\textbf, …) work. But \textbullet is not redefined.

Font loading via plain TeX command

If you need the symbol in one size and shape only, then you could also load the font directly. Then first create a MWE for the symbol with using textcomp:

\documentclass{article}
\usepackage[loading]{tracefnt}
\usepackage{textcomp}
\pagestyle{empty}
\begin{document}
\textordmasculine
\end{document}

Make sure, that the font sizes and families are correct:

  • Correct size option for the document class (10pt, 11pt, 12pt).
  • The MWE contains all other font packages (lmodern, mathptx, …).

Then run the MWE through LaTeX and look for the following information of tracefnt:

LaTeX Font Info:    External font `tcrm1000 at10.0pt' loaded as
(Font)              TS1/cmr/m/n/10  on input line 6.

tcrm1000 at10.0pt can be different depending on the font and size settings. It is the data we need for \newfont:

\documentclass{article}

\newfont{\fonttextcomp}{tcrm1000 at10.0pt}
% \providecommand for the case `textcomp` is loaded.
\providecommand*{\textordmasculine}{%
  \begingroup\fonttextcomp\symbol{186}\endgroup
}

\begin{document}
\textordmasculine
\end{document}

Limitation: The symbol will not resize or is affected by \textbf etc. Each variant requires a new font and macro.

Summary

Because the latest method is cumbersome and has serious limitations, I would recommend the third method (or one of the first three methods).

Result

Result