Text FormattingFormatting based on context, environment

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
manukoch
Posts: 1
Joined: Tue Nov 30, 2010 7:16 pm

Formatting based on context, environment

Post by manukoch »

Hi,
I would like to write a macro that expands differently based on the context it is called in. So in normal text it should expand to value1, but if called in a section title or figure caption it should expand to the same text with different formatting.

I am aware that I should use the ifthenelse environment, but I do not know what condition to test for; maybe anyone of you can help.

What I want here is to avoid some special formatting in headings and captions, maybe there is a other way to do that entirely?

So it should look like this:

Code: Select all

\newcommand{\ExpandMe}{
\ifthenelse{-- we are in normal text -- }
   {\emph{\textsmaller{ExpandMe}}}
   {ExpandMe}
}
Thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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

Post Reply