3

Edited

I want to make the name written in mathematical mode match the style title of the section.

The first lines of my code are

\documentclass[pdftex,12pt,twoside,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{lmodern}
\usepackage{amssymb,amsmath,amsthm}

My document has chapters and sections that appear text and formulas together. If I use

\section{Properties of $Ti_3SiC_2$}

the result is

enter image description here

in the text and

enter image description here

in the index.

To try to correct the difference between font styles in both places, the line of code that I used is:

\subsection[Properties of \texorpdfstring{$\mathrm{ZrB_2+SiC}$}{TEXT}]{Properties of \texorpdfstring{$\mathbf{ZrB_2+SiC}$}{TEXT}}

and the result in the index is

enter image description here

And in the title of the section is

enter image description here

It may seem that the styles match, but no. That is, in both cases the letters of Properties and ZrB_2 look different. Does somebody know anything about this? Now is it better understood?

Pd: I do not want the title of the text and the index to have the same style format. What I intend is that the format of the title with the mathematical expression, and the index with the mathematical expression, be the same.

  • you mean \tableofcontents by "index" ? You have specified \mathrm in one case and \mathbf in the other so naturally they use different fonts? – David Carlisle Jun 22 at 16:35
  • Yes I know. What I am referring to is the same style of print. For example, in the title the word Properties seems to have a calligraphy other than ZrB_2. I do not know if I explain. – Valveroz Jun 22 at 16:47
  • 2
    the font choice is entirely set up in code that you have not shown so it is very hard to say anything unless you provide an example. It is entirely normal for a section heading to use a bold font from a different font family to the main text, and for tables of contents to be set using the main text font not using the heading font. – David Carlisle Jun 22 at 16:50
  • Could you please add a minimal working example (MWE) to your question. Also, you might want to have a look into the mhchem package that is dedicated to typesetting chemical formulae. – leandriis Jun 22 at 17:23
  • 2
    @Valveroz: As already mentioned, you might want to use mhchemas follows: \documentclass[12pt]{report} \usepackage{mhchem} \usepackage[hidelinks]{hyperref} \begin{document} \tableofcontents \section{Properties of \ce{Ti_3SiC_2}} \section{Properties of \ce{ZrB_2 + SiC}} \end{document} This is the output – leandriis Jun 22 at 19:45
2

I guess you are looking for the \boldmath macro. In a standard document

\documentclass{article}

\begin{document}
$\mathrm{ZrB_2+SiC}$ vs. {\boldmath$\mathrm{ZrB_2+SiC}$}
\end{document}

short sample

A possibility that might work for you to avoid too much extra encoding is to add \boldmath to any invocation of \bfseries. This can be done via the internal macro \g@addto@macro via

\makeatletter
\g@addto@macro\bfseries{\boldmath}
\makeatother

in the preamble.

Sample output

\documentclass[pdftex,12pt,twoside,a4paper]{report}

\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{lmodern}
\usepackage{amssymb,amsmath,amsthm}

\makeatletter
\g@addto@macro\bfseries{\boldmath}
\makeatother

\begin{document}
\tableofcontents
\section{Properties of $Ti_3SiC_2$}

\section{Beware bold math $\mathbf{x}y\mathrm{z}$}
\end{document}

As the second heading shows, this will probably not be acceptable if you mix \mathbf and \mathrm in your equations.

0

Use a chemistry package, for instance chemformula (or mhchem):

\documentclass[12pt,twoside,a4paper]{report}

\usepackage{lmodern}
\usepackage{amssymb,amsmath,amsthm}
\usepackage{chemformula}


\begin{document}

\section{Properties of \ch{Ti3SiC2}}

\end{document}

enter image description here

Below a picture showing what you'd get in the table of contents.

enter image description here

Side notes: the pdftex option should not be specified, as packages that need it are able to guess the driver based on the engine used for typesetting. With recent TeX distributions, loading inputenc with the utf8 option is no longer needed (but it makes no harm).

0

For my case in particular, the solution given by @leandriis is perfectly valid. The only thing is that I have a series of warnings like this one

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding): removing \mhchem@cee' on input line 96. and Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding): removing subscript' on input line 96.

Someone knows how it can be solved

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.