TransWikia.com

textbf and textit does not work

TeX - LaTeX Asked on July 25, 2021

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}}
   hfillbegin{minipage}[t]{0.66textwidth}
   raggedright
}
{
   end{minipage}
   vspace*{stretch{3}}
   clearpage
}

makeatletter
renewcommand{@chapapp}{}% Not necessary...
newenvironment{chapquote}[2][2em]
  {setlength{@tempdima}{#1}%
   defchapquote@author{#2}%
   parshape 1 @tempdima dimexprtextwidth-2@tempdimarelax%
   itshape}
  {parnormalfonthfill-- chapquote@authorhspace*{@tempdima}parbigskip}
makeatother

title{Huge textbf{De Maskerede}}
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

One Answer

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}

to your document preamble.

Answered by egreg on July 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP