7

I'm trying to combine \textbf{} with \texttt{} to obtain a code style that is more "fat". I tried to combine first \textbf and then \texttt and viceversa but nothing changed, it seems like \texttt has a priority over \tetxbf:

enter image description here

1
  • 4
    You need to use a font which has a bold typewriter. Oct 23, 2021 at 10:33

3 Answers 3

6

The Courier teletype font family provides both a light/regular and a bold font weight, with the weights looking very distinct.

enter image description here

Other teletype font families, including Latin Modern Mono, provide regular and bold font weights as well; however, their looks aren't as different from one another as in the case of the Courier teletype font.

enter image description here

To generate the preceding screenshot, just replace \usepackage{courier} with \usepackage{lmodern} in the code shown below.

\documentclass{article}
\usepackage{courier} % or: \renewcommand{\ttdefault}{pcr}
\begin{document}
Example \textbf{Example} \texttt{Example} \texttt{\textbf{Example}}
\end{document}
2
  • 1
    Inconsolata is another one they might want to try out.
    – Davislor
    Oct 23, 2021 at 14:48
  • 1
    @Davislor - I fully agree. As a general proposition, I'd say that it can't be a good idea to use a monospaced font whose regular and bold font weights are so similar as to leave readers unsure as to whether a given monospaced word is typeset in regular or bold. That's why I held up Courier as a font to consider using. Inconsolata/Consolas is definitely a fine choice as well.
    – Mico
    Oct 23, 2021 at 19:16
4

With contour package, you can get fatter characters as a type of special effect when the contourlength is set to a relatively small amount:

contour

(contour is designed for printing readable text on top of images, and usually the contour colour would be white or some other light colour)

MWE

\documentclass{article}
\usepackage{xcolor}
\usepackage{contour}
\usepackage{fontspec}
\newfontfamily{\ffmono}{Noto Sans Mono}
\newfontfamily{\ffcourier}{Courier New}
\newcommand{\testtext}{%
\par\bigskip
\begin{tabular}{ll}
font regular &  plain  \\
font bold& \textbf{bold} \\
contour& \contour{black}{bold} \\
contour red and yellow& \contour{red!20}{bold} \contour{yellow}{bold} \\
fatter contour& \contourlength{0.05em} \contour[40]{black}{bold} \contour[40]{red!20}{bold} \contour[40]{yellow}{bold} \\
\end{tabular}
\par
}

\begin{document}
\ttfamily
Default font
\testtext
\bigskip\ffcourier Courier New
\testtext
\bigskip\ffmono Noto Sans Mono
\testtext
\end{document}
3

1. enter image description here

\documentclass{article}
% \usepackage[T1]{fontenc}
\usepackage{lmodern}
\begin{document}
\ttfamily
\fontseries{l}\selectfont light
\fontseries{m}\selectfont medium
\fontseries{b}\selectfont bold
\end{document}
  1. List item

    \documentclass{article}
    % \usepackage[T1]{fontenc}
    \usepackage{lmodern}
    \usepackage{bold-extra}
    
    \begin{document}
    \textbf{qwe} \texttt{qwe} \texttt{\textbf{qwe}}
    \end{document}
    
1
  • 2
    I think this answer would benefit from some additional explenations. Especially to make it more clear that the first example works because of lmodern and not because it uses \fontseries{b} directly. Also the second example does not need bold-extra since it loads lmodern. Maybe you wanted to omit that package there? Oct 23, 2021 at 11:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .