TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using XeLaTeX to take notes in class, and I am using a new section for each lecture. Since the lectures have different teachers, I'd like a small italic subtitle for each \section.

I'm using the article class.

How would I go about doing that?

share|improve this question
up vote 10 down vote accepted

One problem with simply adding some formatted "teacher name" text after \section is that nothing prevents a page break immediately after the teacher name. (By default, LaTeX ensures that a section heading is followed by at least two lines of text.) Therefore I would use the titlesec package and its ability to execute additional code after the section title has been typeset (but still within \section).






\teacher{Donald~E. Knuth}





(The blindtext package is only used to add some dummy text to the example.)

share|improve this answer
What would I have to change to make this work with subsections as well? – Per Enström Feb 11 '11 at 18:37
@InfiniteSquirrel: I believe just change \titleformat{\section} to \titleformat{\subsection}, then adjust the formatting in the three lines following to typeset the subsection how you like. For me, this involved changing \Large to \large and \thesection to \thesubsection, both in the first line following the \titleformat command. – Tim Nov 4 '11 at 13:57

You can define such a command yourself. For example:


This can be used as

share|improve this answer
Should be \teacher{Prof.~Knuth}, shouldn't it? To get the correct spacing I mean. (My German nature tells me to also add the Dr.~, while I'm not sure if the full title is necessary for class notes.) – Martin Scharrer Feb 1 '11 at 17:44
@Martin: Well, I agree it's a good manner to use ~. However, ~ does not modify the spacing, but only mean "nonbreak space". There's no different here (it's very short). – Leo Liu Feb 1 '11 at 17:57
@Leo Liu: There is normally no change in spacing inside normal text if ~ is used, BUT TeX adds an extra wide space after the . because it thinks its the end of a sentence. Using a ~ or \ fixes that. The ~ has the added benefit of being non-breakable as you pointed already out. I would therefore add a \frenchspacing in the flushright environment to directly disable the extra space after .. – Martin Scharrer Feb 1 '11 at 18:11
@Martin: You are right. I forgot that. – Leo Liu Feb 1 '11 at 18:23
Is there any way of eliminating the line spacing between the \section and the \teacher? – Per Enström Feb 1 '11 at 20:42

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.