5

Is it possible to make all numbers followed by a point bold? Having thousands of questions to make bold is a tough effort. For example, if I have answers to some questions like this:

1. $8+2 \cdot 3 + 1 = 15$

2. 5+3=8

3. 4+9 =13

…

Is there any code I can write in the beginning of the document to produce all the 1., 2. etc. in a bold text?

  • 1
    almost certainly- how are you creating the 1., 2., etc? with a list? custom environment? do tell! :) – cmhughes Jun 2 '13 at 21:16
3

TeX is a programming language so you can do most things with a bit of effort, but that doesn't mean you should. The following implements the requested test but the input markup is weird, and the resulting output is horrible. In particular why math mode for the first (because of the \cdot) but not the others (so the fonts and spacing are all wrong).

You should almost never number anything explicitly in LaTeX it is set up to number and cross reference automatically.

enter image description here

\documentclass{article}
\makeatletter
\def\mytest{\afterassignment\mytestx\hmm0}
\def\mytestx{\@ifnextchar.\mytestxx{\ifnum\hmm>\z@\the\hmm\space\fi}}
\def\mytestxx.{\textbf{\the\hmm.}}
\makeatother
\begin{document}
\everypar{\mytest}
\newcount\hmm

Some words

1. $8+2 \cdot 3 + 1 = 15$

2. 5+3=8

3. 4+9 =13

123. 14-49 =horrible


More words

1 has no dot.

\end{document}
6

You can use the enumitem package to have the labels for all enumerate environment in boldface:

\documentclass{article}
\usepackage{enumitem}

\setlist[enumerate]{label=\bfseries\arabic*.}

\begin{document}

\begin{enumerate}
\item First.
\item Second.
\end{enumerate}

\end{document}

enter image description here

You can use

\setlist[enumerate]{label=\bfseries\arabic*.,ref=\arabic*}

if cross-references are not to be nold-faced.

Without additional packages, you can do a redefinition of \theenumi:

\documentclass{article}

\renewcommand\theenumi{\textbf{\arabic{enumi}}}

\begin{document}
\begin{enumerate}
\item First.
\item Second.
\end{enumerate}

\end{document}
  • I don't want a regular list. I want it to begin with, for example, 1301 or 1301 and so on. Is there way to produce bold text without adding \item? – user30523 Jun 3 '13 at 6:37
  • @user30523 Do you mean that you want numbers followed by a period to be formatted as bold automatically? That sounds awfully complicated (that would probably require two passes), and, if you think about it, is undesirable. What if, for example, you end a sentence with a digit ("9", say); I'm pretty sure you don't want 9. to appear bold in that case. I'd say you're better off using some markup to do that; Gonzola's answer makes sense. – jub0bs Jun 3 '13 at 9:21
  • @user30523 I agree with Jubobs; it's better to have the markup. If you want to start the enumeration in a customized value, using my first solution you can say \begin{enumerate}[start=1308]\item text\end{enumerate}. – Gonzalo Medina Jun 3 '13 at 13:24

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.