6

I am using \boldsymbol{} and \textit{}, but they are not recognized. The document preamble is the following:

\documentclass{book}
\usepackage[spanish]{babel}
\selectlanguage{spanish}
\usepackage[utf8]{inputenc}
\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
\usepackage{parskip}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{amsmath, calc}
\usepackage[margin=1.5in]{geometryit is}
\usepackage{hyperref}
\usepackage{textcomp}
\usepackage{listings}
\usepackage[svgnames]{xcolor}
\usepackage{fontspec}
\usepackage{mathptmx}
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage[numbers]{natbib}
\begin{document}

For example, I'm using $\boldsymbol{x}_t$ and 
\textit{vector de estados} within a paragraph.

\end{document}

Which lines concern the font or the commands that are not working? What should I change?

David Carlisle
  • 757,742
Alfie González
  • 163
  • 1
  • 2
  • 4
  • 1
    You have an issue with \usepackage[margin=1.5in]{geometryit is}... that's completely irrelevant to your question, but it remains a problem. – Werner Dec 13 '17 at 22:53
  • It should be \usepackage[margin=1.5in]{geometry} since there's no package called geometryit is. – Werner Dec 13 '17 at 22:57
  • 6
    In answer to your question, \textit is available by default and \boldsymbol is supplied by amsmath (even though \bm from bm is a suggested improvement/alternative). – Werner Dec 13 '17 at 22:58
  • 1
    But if I'm using \usepackage{amsmath, calc}, why is \boldsymbol{} not working? And if \textit{} is default, why is it not working either? – Alfie González Dec 13 '17 at 22:59
  • There's nothing that points to \textit being disable/unavailable based on your code snippet. So the problem must be somewhere else... – Werner Dec 13 '17 at 23:16
  • But should I change the font or something of the kind? – Alfie González Dec 13 '17 at 23:17
  • Nothing in your current code snippets points to being problematic (except for the geometryit is missing package). – Werner Dec 13 '17 at 23:19
  • For example, I'm using $\boldsymbol{x}_t$ and \textit{vector de estados} within a paragraph. Is something wrong with that? – Alfie González Dec 13 '17 at 23:36
  • @AlfieGonzález: Nothing is wrong with that... – Werner Dec 13 '17 at 23:49
  • you need to fix your example so that people can run it and see the problem. the example needs to be complete from \documentclass to \end{document} – David Carlisle Dec 14 '17 at 00:11
  • oh you are using mathptmx which does not have bold math fonts, so that explains \boldsymbol (try newtxtext,newtxmath instead – David Carlisle Dec 14 '17 at 00:16
  • you are using packages designed for pdftex (inputenc, mathptm) but then using fontspec which requires xetex or luatex. This is going to lead to errors. Are you using pdflatex (if so remove fontspec) or xetex or luatex (in which case remove inputenc, and mathptmx) – David Carlisle Dec 14 '17 at 00:20
  • That worked! I commented the lines with inputenc and mathptmx and the bold symbols and italics appeared. – Alfie González Dec 14 '17 at 00:49

2 Answers2

4

Please use the package bm in the preamble:

\usepackage{bm}

And in document use

\bm{}

For examples, bold symbols with italic shape are

$\bm{\alpha}=\bm{t}$

compared with them, the normal symbols are

$\alpha=t$

The compiled PDF for them would be

enter image description here

By the way,

  • in fact \bm{} won't change any shape of symbols but only increase
    the thickness of symbols.
  • bm package can be used under every mathematical fonts, including mathptmx you used.
M. Logic
  • 4,214
  • 2
    bm can really only make acceptable output if there is a bold font available (it can use poor man's bold, overprinting three copies of the symbol with slight offsets, but that's not recommended) – David Carlisle Dec 14 '17 at 07:47
  • 2
    Another reason to stick to boldsymbol is that the command is avaiblable by default in Mathjax, which comes in handy e.g. when writing documentation with Doxygen. – Rastapopoulos Feb 14 '18 at 17:08
  • @DavidCarlisle A quotation from your book the 'LaTeX companion' (2nd edition): "Although amsmath provides \boldsymbol and \pmb, the rules about about when to use which command, and many of the restrictions on when they work, can now be avoided: just load the bm package and use \bm to make any formula as bold and beautiful as the available fonts allow''. ;) – loved.by.Jesus Feb 23 '21 at 14:27
2

enter image description here

\documentclass{book}
\usepackage[spanish]{babel}
\selectlanguage{spanish}
\usepackage[utf8]{inputenc}
\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
\usepackage{parskip}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{amsmath, calc}
\usepackage[margin=1.5in]{geometry}
\usepackage{hyperref}
\usepackage{textcomp}
\usepackage{listings}
\usepackage[svgnames]{xcolor}
%\usepackage{fontspec}
\usepackage{mathptmx}
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage[numbers]{natbib}

\begin{document}

For example, I'm using $\boldsymbol{x}_t$ and \textit{vector de estados} within a paragraph.
\end{document}

mathptmx is very old and has no bold fonts, a better times clone is newtxmath

enter image description here

\documentclass{book}
\usepackage[spanish]{babel}
\selectlanguage{spanish}
\usepackage[utf8]{inputenc}
\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
\usepackage{parskip}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{amsmath, calc}
\usepackage[margin=1.5in]{geometry}
\usepackage{hyperref}
%\usepackage{textcomp}
\usepackage{listings}
\usepackage[svgnames]{xcolor}
%\usepackage{fontspec}
%\usepackage{mathptmx}
\usepackage{newtxtext,newtxmath}
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage[numbers]{natbib}

\begin{document}

For example, I'm using $\boldsymbol{x}_t$ and \textit{vector de estados} within a paragraph.
\end{document}
David Carlisle
  • 757,742