Text Formatting ⇒ Format of math mode in titles
Format of math mode in titles
\chapter{Quadratic: $x^2$}
\section{The properties of $\mathrm{A_B}$}
Unfortunately these math commands are typeset with the normal font weight rather than bold, as titles should be. The result looks incongruous. For these simple examples I could cheat and use \mathbf{}, but my real application uses a complicated macro to generate the math for insertion. How do I get latex to format the math in a manner more consistent with the other title text?
Thanks,
-AM
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Format of math mode in titles
Code: Select all
\chapter[Quadratic: $x^2$]{Quadratic: $\boldsymbol{x^2}$}
\section[The properties of $\text{A_B}$]{The properties of $\boldsymbol{\text{A_B}}$}Best regards and welcome to the board
Thorsten¹
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Format of math mode in titles
1) This isn't that much better that adding \mathbf{} to everything, which is what I'm trying to avoid.
2) $\text{A_B}$ doesn't work, but $\text{A}_\text{B}$ does. In fact it works really well -- \text{} takes the font/weight of the surrounding text, so you don't need the \boldsymbol at all. This is great for situations where I'm just trying to take advantage of super/subscripts for text. Unfortunately, I want more than that (I oversimplified my example).
But this gives me some ideas... I'll be back
Re: Format of math mode in titles
\newcommand{\allbold}[1]{\textbf{$\boldsymbol{#1}$}}
So it will work on macros like the following that contain both
\newcommand{\mac}{\ensuremath{\bar{\text{A}}^{2}}}
Now, the real question is how do you avoid this altogether? I don't really want to add \allbold to all my titles. How does \text{} work that it knows about and mimics the font settings immediately outside the math environment? Is it possible to make the math environment itself behave the same way, at least on macros?
I'll stop rambling now. This works well enough. Thanks for your help.
Format of math mode in titles
Code: Select all
\documentclass{report}
\makeatletter
\DeclareRobustCommand*{\bfseries}{%
\not@math@alphabet\bfseries\mathbf
\fontseries\bfdefault\selectfont
\boldmath
}
\makeatother
\begin{document}
\tableofcontents
\chapter{Quadratic: $x^2$}
\section{The properties of $A_B$}
\end{document}Re: Format of math mode in titles
You mention that there are better solutions. What makes this worse? Are there situations in which I should not use it?
Thanks again.
Re: Format of math mode in titles
-
Now_its_me
- Posts: 1
- Joined: Thu Jan 28, 2021 1:06 am
Format of math mode in titles
\newcommand\tado{%
\mathrel{\ooalign{\hss$\curlyvee$\hss\cr%
\kern .35ex \raise .8ex\hbox{\scalebox{.5}{$\mathbf{\times}$}}}}}The problem I am having is that while it looks fine in bold in the Chapter and section titles and whatnot, the overlaid symbol appears in a different location when not bolded than when bolded. Now I could make two versions of the symbol such that they match up properly and define something like
\boldtado. I was wondering if there was a way to change the \makeatletter
\DeclareRobustCommand*{\bfseries}{%
\not@math@alphabet\bfseries\mathbf
\fontseries\bfdefault\selectfont
\boldmath
}
\makeatother or make a new Robust Command such that if I have \tado in the heading then it will automatically choose an alternate \boldtadothat is defined identically with the exception of having different \kern and \raise values.- Ijon Tichy
- Posts: 640
- Joined: Mon Dec 24, 2018 10:12 am
Format of math mode in titles
\boldmath to the font setting of the title but not the ToC entry or page header, e.g.
Code: Select all
\documentclass[twoside]{scrreprt}
\usepackage{blindtext}
\addtokomafont{disposition}{\boldmath}% use bold math in titles
\pagestyle{headings}
\begin{document}
\tableofcontents
\chapter{Quadratic: $x^2$}
\section{The properties of $A_B$}
\Blindtext[10]
\end{document}\texttimes, that can be uses in text mode instead of switching to math mode. With old LaTeX kernels you need to load package textcomp. Up-to-date LaTeX kernels have build in \texttimes. See the fntguide (section 7 in the current release) for more information about such text symbol commands.