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.

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 have made this command:

\subsubsection{{\bf Example #1}{{\color{lightgray}\hrule width 22mm height 1.5pt}\hfill}}%

and it's working fine, unless if I m trying to put an \example inside an itemize or enumerate environment, in which case the line is not indented, and so it's not aligned nicely underneath the indented "Example". I thought about using a rule instead of an hrule {\color{lightgray}\rule{\linewidth}{1.5pt}}

but this doesn't seem to work inside the subsubsection. It produces an error. Any suggestions? I'd prefer to avoid using extra packages if possible. Thanks!

share|improve this question
up vote 3 down vote accepted

You can't use \subsubsection in an itemized or enumerated list.

Perhaps this code does what you want:


  \noindent\textbf{\examplerule\theexample\ Example #1}\par\vspace{1ex}

EDIT: this will draw a line as wide as the example label and also allow for \example* that doesn't print a number, nor step the example counter.


    \def\exampletext{\textbf{\theexample\ \examplename\ #1}}%
    \def\exampletext{\textbf{\examplename\ #1}}%

You can define \examplename as you wish.

share|improve this answer
this looks great! thanks! any easy way to change "22mm" that I had put to match the word's size? I will be changing the word example to the equivalent word in greek, and sometimes there won't be a number next to it. BTW, why do you say subsubsection is not working inside at itemized environment? the code i had included works just fine with itemize, it's the rule i was having trouble with.. – sfranky Oct 9 '11 at 13:35
I've edited the answer: you can use \example* for unnumbered examples and the rule width covers all of the label. – egreg Oct 9 '11 at 13:53
thanks very much! you've been most helpful!! – sfranky Oct 9 '11 at 17:24

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.