Text Formatting ⇒ One command for "bold" both in text and math mode
One command for "bold" both in text and math mode
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
- svend_tveskaeg
- Posts: 478
- Joined: Sun Jul 12, 2009 5:31 am
One command for "bold" both in text and math mode
-- Zapp Brannigan, Futurama (season 1, episode 4)
One command for "bold" both in text and math mode
Code: Select all
\let\oldtextbf=\textbf
\renewcommand\textbf[1]{{\boldmath\oldtextbf{#1}}}
Code: Select all
\newcommand\allbold[1]{{\boldmath\textbf{#1}}}
Re: One command for "bold" both in text and math mode
Thanks to all.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
One command for "bold" both in text and math mode
You can implement it in exactly that way.Alextorm wrote:I had in mind something like an "if-then" construction ("if math environment do math bold, if text environment do text bold"), but yoriz solution is just perfect for me.[…]
Code: Select all
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\newcommand*{\genbf}[1]{\ifmmode\mathbf{#1}\else\textbf{#1}\fi}
\begin{document}
\genbf{In-line text}
\[
\genbf{Math}
\]
\end{document}Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10