[Tex/LaTex] How to Bold and Italic a particular word throughout the document in latex

bolditalic

I need to use Bold or Italic a particular word through my latex document, where ever it is used, without explicitly mentioning textbf{} and textit{} on each of them. How can I do that?

A good analogy would be, CSS to HTML tags.

Is it possible to this in Latex?

Best Answer

Here is \mymarkup in a starred and unstarred variant. The unstarred variant gives \textbf{...} and the starred one is responsible for italic version. The double starred version gives bold and italic and the optional parameter changes the text:

\documentclass{article}



\usepackage{xparse}

\NewDocumentCommand{\mymarkup}{ssO{myword}}{%
  \IfBooleanTF{#1}{%
    \IfBooleanTF{#2}{%
      {\bfseries\itshape #3}%
    }{%
      \textit{#3}%
    }%
  }{%
    \textbf{#3}%
  }%
}


\begin{document}
\mymarkup\ is better than \mymarkup*\, which is followed by \mymarkup**\ again

\mymarkup[Don't use xspace]\ is better than \mymarkup*[Don't use xspace]\, which is followed by \mymarkup**[Don't use xspace]\ again


\end{document}

enter image description here