Hot answers tagged

233

In my experience, there is no single best way. Therefore Table 528 on page 225 of the Comprehensive LaTeX Symbol List comes in really handy. (Visited March 8, 2019 )


64

\documentclass{article} \usepackage{xcolor} \begin{document} ~\\ \colorbox{pink}{highlight}\\ \colorbox{green}{highlight}\\ \colorbox{yellow}{highlight}\\ \bfseries\colorbox{pink}{highlight + boldface}\\ \colorbox{green}{highlight + boldface}\\ \colorbox{yellow}{highlight + boldface}\\ \color{red}\colorbox{pink}{highlight + boldface + colored text}\\ \...


55

Here's a solution that I've found to work very well -- add the following to your document preamble \makeatletter \g@addto@macro\bfseries{\boldmath} \makeatother (or just add the middle line to a .sty/.cls file, where the at-symbol escaping isn't needed.) This just modifies that \bfseries macro to include \boldmath. You also need to make sure that your font ...


54

Since biblatex 3.4/biber 2.5, there is a general "annotation" functionality to do things like this, for example: \documentclass{article} \usepackage{biblatex} \usepackage{filecontents} \begin{filecontents}{\jobname.bib} @MISC{test, AUTHOR = {Last1, First1 and Last2, First2 and Last3, First3}, AUTHOR+an = {2=highlight}, } \end{filecontents} \...


48

If you want the whole item bold, you can write: \begin{enumerate}\bfseries \item The firs item \item The second item \end{enumerate} If you want the number to be bold, you can do it by using the enumitem package and setting: \begin{enumerate}[label=\textbf{\arabic*})] \item The firs item \item The second item \end{enumerate} Check the enumitem package ...


41

There is also \boldsymbol{} from the package amsbsy (loaded by amsmath). See this question for a discussion of the advantages and disadvantages of each command.


39

There are the Latin Modern Fonts, from their README: The fonts are based on Donald E. Knuth's Computer Modern fonts in the PostScript Type 1 format In family lmtt, there are even three series: \documentclass{article} % \usepackage[T1]{fontenc} \usepackage{lmodern} \begin{document} \ttfamily \fontseries{l}\selectfont light \fontseries{m}\selectfont ...


33

Your issue is "font-dependent". Background Indeed, special shapes of a font (bold, italic, slanted, small caps) are not defined relatively to a main font (its regular shape), but independently. The "bold version" of a font is defined per se (it is an independent *otf, *.ttf-file you can install and use, even if you don't have the main/regular version), and ...


29

Assuming you do want fixed line ends: \documentclass{article} \newcommand\dob[1]{\textbf{#1}} \newenvironment{boldfirst}{\obeylines\everypar{\dob}}{} \begin{document} \begin{boldfirst} Lorem ipsum dolor sit amet, consectetur adipisci elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ...


26

What I did, is to declare my own command for a vector, well its pretty basic, but you can add other features, like an arrow. \newcommand{\vect}[1]{\boldsymbol{#1}} And the usage: \vect{X} = \left[x_1,x_2,\ldots,x_n \right]^T returning:


26

While \bm and \boldmath are some good options in LaTeX, modern packages for XeLaTex can give a lot more control over the fonts from the very beginning, without the need to use commands different from the standard \mathbf that every one expects naively to work the first time one tries to write bold italic characters. In XeLaTeX (part of TeXLive), the package ...


25

Is there any reason(s) not to use \let to redefine \bf to \bfseries and \it to \itshape? Yes, there are good reasons. :-) With the above \let-based setup, {\bf\it ...} produces bold-italic. In contrast, in a plain-TeX document {\bf\it ...} produces italic text. If the goal is to make \bf and \it behave the same way in LaTeX and plain-TeX, the \let-based ...


24

As I couldn't use https://tex.stackexchange.com/a/73246/7561 as well, and in case others stumble into this looking for a solution, I'm updating the answers. As pointed by Adam Liter, in the comments of that answer, the options used in the previous answer are deprecated and doesn't work (at least for me). Solution Instead, I redefined the \mkbibnamegiven ...


24

Here's a more complicated version that tries to preserve kerning between the first two letters, as shown in the last two lines. As in Thruston's answer, accented first characters must be enclosed in braces. \documentclass{article} \usepackage[T1]{fontenc} \usepackage{environ,expl3} \ExplSyntaxOn % with the help of \NewEnviron, boldfirst absorbs the % ...


24

BBB stands for blackboard bold, but "double struck" is also used (e.g. ℝ). However how it should be pronounced is another matter -- between reading out the markup ("dollar dollar backlash B B B space R") and the meaning of the symbol ("set of real numbers" is a big gap.


23

The commands \rm, \bf etc are called "deprecated" because they have been removed from the latex kernel. The way the commands work don't fit in the (much better) "new font selection scheme" (nfss) used by latex2e. A number of classes nevertheless provide the definitions for these commands, but the definitions differ. E.g. memoir: \@memoldfonterr {\rm }{\...


22

A different option is to use the Latin Modern fonts, that sport a fully featured boldface typewriter font. They have also another feature, because they can use a lighter version for the medium weight: \usepackage[lighttt]{lmodern} Let's compare a couple of examples: \documentclass{article} \usepackage[T1]{fontenc} \usepackage{lmodern} \begin{document} ...


22

The best way to do this would be to use the escapeinside command, like this: \documentclass{article} \usepackage{listings} \lstset{ escapeinside={(*}{*)} } \begin{document} \begin{lstlisting} //Algoritmo 2 int f2 ( n ): local i , j , r =0; para i = 1 a n -1 para j = i +1 a n r = r + 2; (*\bfseries cont++;*) ...


22

Maybe this? I introduce a \setrow{...} macro invoked on the first element of a row, which applies to each cell of that row (and is then reset). It employs the >{} and <{} feature of tabularx. \documentclass{article} \usepackage{tabularx} \newcommand\setrow[1]{\gdef\rowmac{#1}#1\ignorespaces} \newcommand\clearrow{\global\let\rowmac\relax} \clearrow \...


21

Here are some ways to bold a text (and only this text, not the following part of the document): \textbf{Text to bold} {\bfseries Text to bold} \bfseries Text to bold \mdseries One can also mention this one but it is not recommended since bfseries is not an environment. However it works... \begin{bfseries} Text to bold \end{bfseries} In math-mode, use the ...


21

Two suggestions: Use the "long title" -- the stuff inside curly braces -- to typeset the material in the way you want it to appear in the sectioning header itself; in particular, use \bm (or an equivalent macro) to create bold math symbols. Use the \texorpdfstring macro (provided by the hyperref package) inside the "short title" -- the stuff inside square ...


20

Internally \boldsymbol effectively uses \boldmath so sets up an entire bold math setup whatever symbols are actually used in bold, hence you get this warning. The silence package gives an interface for filtering out various LaTeX messages so you could filter out these or in this case, stmaryrd uses \SetSymbolFont{stmry}{bold}{U}{stmry}{b}{n} ...


19

This is in response to this comment by Raffi Khatchadourian on the accepted answer: "I see a problem here: this answer is redefining the numbering style completely instead of enhancing it, i.e., making the number part bold." If you would like to avoid this problem with the top two answers, then there are two different solutions, one local and one global, ...


19

You can make a small extension to the metalogo package, which enables you to choose a different initial “L”. \documentclass{article} \usepackage{metalogo} \usepackage{xpatch} \makeatletter \newcommand{\setLaTeXL}[1]{\def\xl@LaTeXL{#1}} \xpatchcmd{\LaTeX}{L}{\xl@LaTeXL}{}{} \makeatother % initialize \setLaTeXL{L} \newcommand{\BLaTeX}{{\setLaTeXL{\textbf{L}}...


19

The idea behind \emph is that it provides a high level way for giving emphasis to a part of the text. High level in the sense it is “independent” of the actual implementation. The default behavior of \emph is to use italics when in an upright context and upright when in an italics context, but this can be modified on a document’s basis (or by a package ...


18

You can use the bm-package \documentclass[paper=a4, fontsize=12pt]{article} % A4 paper and 11pt % font size \usepackage[english]{babel} % English language/hyphenation \usepackage{amsmath,amsfonts,amsthm,bm} % Math packages \begin{document} \begin{align*} (\mathbf{n}\cdot \bm{\sigma}) \sigma&=\mathbf{0} \end{align*} \end{document}


17

Load a font that has the combination bf+it, e.g. \usepackage{lmodern} MWE \documentclass{beamer} \usetheme{Copenhagen} \usepackage{lmodern} \begin{document} \frame{ A number is \textbf{\textit{x}-smooth} if ...\\ A number is \textbf{\emph{x}-smooth} if ... } \end{document}


17

I just ran across it and found a simpler answer here: https://en.wikibooks.org/wiki/LaTeX/Fonts \usepackage{bold-extra} ... \texttt{TT Text \textbf{Bold TT Text}}


Only top voted, non community-wiki answers of a minimum length are eligible