# \textbf and \textit does not work

So I have a main.tex that looks like this:

\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage[danish, english]{babel}
\usepackage{xspace}

\newenvironment{dedication}
{
%\cleardoublepage
\thispagestyle{empty}
\vspace*{\stretch{1}}
\hfill\begin{minipage}[t]{0.66\textwidth}
\raggedright
}
{
\end{minipage}
\vspace*{\stretch{3}}
\clearpage
}

\makeatletter
\renewcommand{\@chapapp}{}% Not necessary...
\newenvironment{chapquote}[2][2em]
{\setlength{\@tempdima}{#1}%
\def\chapquote@author{#2}%
\parshape 1 \@tempdima \dimexpr\textwidth-2\@tempdima\relax%
\itshape}
{\par\normalfont\hfill--\ \chapquote@author\hspace*{\@tempdima}\par\bigskip}
\makeatother

\author{\textsc{Niklas}}

\begin{document}

\frontmatter
\maketitle
\tableofcontents
\mainmatter

{\fontfamily{times}\selectfont
\chapter{\textit{Prolog}}
\input{Prolog/Post.tex}

\end{document}


And my post.tex file looks like this:

hi this is \textbf{bold}


When I do a \textbf inside the main.tex it works (like the \title), but when I do a \textbf in one of the input files (like \input{Prolog/Post.tex}), it does not work. I can't figure out the reason why.

Best regards Niklas

• Welcome to TeX.SE! Currently your question is difficult to answer, because we don't know the contents of your Post.tex file. Other relevant information that changes the behavior of your document may be inside commands.tex, which is also unknown. It would therefore be helpful if you could either provide the contents of those files, but even better if you could reduce the code of those files and your main file to the minimum code that still reproduces the issue, and edit your question to show this minimal code. Jan 8, 2021 at 9:27
• Hi, thanks for your reply. I have removed the commands.tex and tried just a simple line in the post.tex - I have tried removing the irrelevant stuff Jan 8, 2021 at 9:39
• You can replace that \input with just the contents of that file, it does not make any difference Jan 8, 2021 at 9:44
• There is no font family called times as you will see from the log. Additionally, if the base language here is suppose to be danish then make sure it is loaded as the last option to babel not the first Jan 8, 2021 at 9:47
• @Niklas you get them on Overleaf as well. Open the log file and have a look. Jan 8, 2021 at 10:04

You can reproduce exactly the same issue with the following minimal example.

\documentclass{article}

\begin{document}

\fontfamily{times}\selectfont

\textbf{bold}

\textit{italic}

\end{document}


Upon running LaTeX on it, you'll be greeted with some warnings:

LaTeX Font Warning: Font shape OT1/times/m/n' undefined
(Font)              using OT1/cmr/m/n' instead on input line 5.

LaTeX Font Warning: Font shape OT1/times/b/n' undefined
(Font)              using OT1/times/m/n' instead on input line 7.

LaTeX Font Warning: Font shape OT1/times/m/it' undefined
(Font)              using OT1/times/m/n' instead on input line 9.


The first one means that LaTeX doesn't know about a times font family and does the default substitution for it, namely with the cmr font family.

The other two warnings are related to the same issue. LaTeX has defined a font corresponding to OT1/times/m/n but just as an alias to a fixed substitution font and hasn't set up the whole font family, because it knows nothing about it. So the subsequent font substitutions can only point to the only known font.

If you want to typeset your document in a Times clone, add

\usepackage{newtxtext,newtxmath}