0

Is there a way to make a certain word bold every time in comes in the document?

Thanks.

VesDyl
  • 13
  • by far the best way is just to use \textbf{word} any text editor can add \textbf{..} around every occurrence of word far quicker and more accurately than it would take to program tex macros to try to do this – David Carlisle Nov 19 '16 at 16:42

2 Answers2

0

You can create a command with \newcommand, inside the document. For example:

\newcommand{\boldword}{\textbf{supercalifragilisticexpialidocious~}}

You can use the new command created inside the document anytime.

\documentclass[]{article}
\begin{document}
\newcommand{\boldword}{\textbf{supercalifragilisticexpialidocious}}
This word \boldword\ is bold.
\end{document}
  • 2
    Welcome to TeX.SX! Something is missing, isn't it? – egreg Nov 19 '16 at 16:47
  • What happens if you wish period after the bold word? – Sigur Nov 19 '16 at 16:50
  • I just realized that I didn't put the space command. But I don't know if that's what you meant. – Mihdi Caballero Nov 19 '16 at 16:51
  • You could just add a period after it. \newcommand{\boldword}{\textbf{supercalifragilisticexpialidocious.~}} – Mihdi Caballero Nov 19 '16 at 16:52
  • 3
    @MihdiCaballero, the command should work in any situation. For example, in the middle sentence or at the end. So you can not insert the blank space in its definition. You have to insert when you use it, like This word \boldword\ is bold. – Sigur Nov 19 '16 at 16:55
  • 1
    Hard-coding a space into the command is not good advice. There are better options: (1) \newcommand\boldword{\textbf{word}} and usage: \boldword\ (or \boldword<punctuation> when word ends a clause or sentence; (2) \def\boldword/{\textbf{word}} usage: \boldword/ (where / must be written or there'll be an error); (3) \usepackage{xspace} \newcommand\boldword{\textbf{word}\xspace} usage: \boldword. Overall, I'd recommend (1) or, in the right circumstances, (2); (3) should generally be avoided because it relies on \def. – jon Nov 19 '16 at 17:33
  • @jon Don't you mean (2) should be avoided? – cfr Nov 19 '16 at 23:00
  • @jon I meant: you said to avoid (3) because it uses \def but didn't you mean (2) since (2) uses \def and (3) does not? – cfr Nov 20 '16 at 00:18
  • 1
    @cfr -- Oops! Yes, exactly!! Avoid (2). – jon Nov 20 '16 at 00:27
0

In case your text is already written you could use the search and replace feature of your favorite editor (or commandline tools like sed/awk) to add \textbf{} around the word in question, but you'll have repeat that for every form of the word.