Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've got to format some text in the style of the section header. So what I would like to do is sort of "get" the parameters that define the section header (i.e. size, formatting, fontstyle) and apply that to the text. However, I'm too much of a newbie in tex and googling didn't really help me out.

I'd rally appreciate hints :-)

share|improve this question
as in “read the source and copy it”, or do you want a macro that works out what’s in the current definition of \section and proceeds from there? –  wasteofspace Sep 19 '12 at 8:44
More like read the source size, source format and source font (latter if necessary) and the apply it to the text –  JoeD Sep 19 '12 at 8:52

1 Answer 1

up vote 5 down vote accepted

The current font identifier can be accessed to with \the\font. So this works:



\section{Some text just to see the result}

The following quotation will use the section font
Some text just to see the result


We typeset a mock section title without printing it, but we use it to access the font. It's better to do it "at begin document" so all packages have been loaded.

The two lines should be the last before \begin{document}; with them you'll have the declaration \TheSectionFont to choose the font available also in definitions you make before those two lines (provided they don't typeset any text).

Just some more information. We need the low level \xdef because we want that

  1. the meaning of \TheSectionFont is known outside the \vbox which makes a group;

  2. the combination \the\font is expanded at the moment of the definition.

\xdef is equivalent to \global\edef; with a simple \def this wouldn't work, because \the\font always refers to the current font. On the other hand, \the can be expanded and when followed by \font the expansion is precisely the internal command that TeX uses to select the current font.

share|improve this answer
Works like a charm :-) Thanks a lot! –  JoeD Sep 19 '12 at 8:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.