My question is closely related to this one. The solution there works fine for text, but here is my scenario.
I want to typeset the names of all packages specially, so it is clear what I refer to. For this, I defined the command:
\newcommand*{\pkg}[1]{\textsf{\detokenize{#1}}}
I use \detokenize
because I have to use _
often in the name of a package, so it I don't want the extra \
. Also, sometimes I copy-paste the name from somewhere, so it already has the form package_name
.
I am using lmodern
fonts, mostly out of inertia. Surely, if you can suggest a better font which has a decent underscore and looks nice, that's great. I tried palatino
and times
, as suggested in the related question. I don't like palatino
. times
could work, but the \textsf
seems too big in relation to normal text.
\documentclass[12pt]{report}
\usepackage{lmodern} % use modern latin fonts
\usepackage[T1]{fontenc} % use 8 bit output font encoding with more glyphs
\usepackage[utf8]{inputenc} % so you can type ă
\usepackage{relsize} % allows you to resize individual characters e.g. underscore
\renewcommand{\_}{\textscale{.5}{\textunderscore}}
\newcommand*{\pkg}[1]{\textsf{\detokenize{#1}}} % typeset the name of a package: \pkg{tum_ardrone}
\newcommand*{\ds}[1]{\textsl{\textsf{\detokenize{#1}}}} % and of a dataset \ds{RIMES}
% these complicated definitions ensure that you always get correct spacing after the command
% and that you cannot forget the correct form (e.g. \FRCNN{}) because this would give you
% bad spacing; and that the name is not hyphenated
\makeatletter
\@ifdefinable{\FRCNN}{\def\FRCNN#{\mbox{\pkg{Faster R-CNN}}}}
\@ifdefinable{\CTPN}{\def\CTPN#{\mbox{\pkg{CTPN}}}}
\@ifdefinable{\RESNET}{\def\RESNET#{\mbox{\pkg{ResNet-101}}}}
\@ifdefinable{\CRNN}{\def\CRNN#{\mbox{\pkg{CRNN}}}}
\makeatother
\begin{document}
Template\_bin % works
\pkg{Template_bin} % nope
\end{document}
Edit: Forgot to say that I use things like \section{The \pkg{Template_bin}}
, \caption[\pkg{Pkg_name}]{...}
etc . Ideally, it would work there too, but if it's too difficult I guess I can find a workaround or not use \pkg{}
there.
palatino
nortimes
affects the sans-serif font. Why do you have special characters in filenames? This is just asking for trouble, surely?_
is a way of avoid trouble with spaces in filenames ?