Text Formatting ⇒ Automatically format keywords (bold, italicize, etc)
Automatically format keywords (bold, italicize, etc)
Latex editor of choice: TexWorks (for dual view feature)
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Automatically format keywords (bold, italicize, etc)
I'm guessing you want certain words in your document having a specific format:
Code: Select all
\newcommand{\keyword}{\textit{keyword}}
\newcommand{\keyword}{\textbf{keyword}}
Follow howtoTeX on twitter
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Automatically format keywords (bold, italicize, etc)
Are we talking about a code listing or just about emphasis of words?ptrcao wrote:Is there a command or package that will allow me to automatically format keywords (bold, italicize, etc)? How do I do this?
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Automatically format keywords (bold, italicize, etc)
Isn't there a function that will search for all instances of the keyword and format it according to my desire?
This approach
Code: Select all
\newcommand{\keyword}{\textit{keyword}}
\newcommand{\keyword}{\textbf{keyword}}
Code: Select all
\newcommand{\keyword}{\textit{keyword }}
Latex editor of choice: TexWorks (for dual view feature)
Automatically format keywords (bold, italicize, etc)
Code: Select all
usepackage{xspace}
\newcommand{\keyword}{\textit{keyword\xspace}}
Follow howtoTeX on twitter
Automatically format keywords (bold, italicize, etc)
Code: Select all
\newcommand{\The Lord of The Rings}{\textit{The Lord of The Rings}}
Latex editor of choice: TexWorks (for dual view feature)
Automatically format keywords (bold, italicize, etc)
For your Lord of Rings question: That's a nasty one. Isn't it possible (and easier) to define:
Code: Select all
\newcommand{\lotr}{\textit{The Lord of The Rings}}
Follow howtoTeX on twitter
Automatically format keywords (bold, italicize, etc)
Ah yes, how convenient, I see somebody came up with a function just for this very situation; it appears \xspace takes care of it all so you don't have to think about it.Frits wrote:I edited my post above for a fix on that whitespace at the end.
For your Lord of Rings question: That's a nasty one. Isn't it possible (and easier) to define:Code: Select all
\newcommand{\lotr}{\textit{The Lord of The Rings}}
I originally thought you could do
Code: Select all
\newcommand{\The-Lord-of-The-Rings}{\textit{The Lord of The Rings}}
Code: Select all
\newcommand{\The_Lord_of_The_Rings}{\textit{The Lord of The Rings}}
And right, your suggestion
Code: Select all
\newcommand{\lotr}{\textit{The Lord of The Rings}}
Latex editor of choice: TexWorks (for dual view feature)