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.

While drafting a text, I want to subdivide and group text pieces and keywords to easily reorder them throughout the document.

Examples for such a group of text pieces would be:

Example 1): Two arguments (2nd is optional and multi-line)

Having in the LaTeX file something like...

\mycommand{Summary of this paragraph (always provided)} {
    optional textline 1
    optional textline 2

...should result in the pdf as...

Summary of this paragraph (always provided)

  • optional textline 1
  • optional textline 2
  • ...

Example 2): One argument

Having in the LaTeX file something like...

\mycommand{Summary of this paragraph (always provided)}

...should result (without optional arguments) in the pdf as...

Summary of this paragraph (always provided)

I tried already some things with \newcommand but I'm not a real expert.

The needed features would be

  • \mycommand gets at least one argument and prints this to the PDF (e.g. in bold letters)
  • \mycommand takes a variable number of following lines (in parenthesis) as second argument and adds for each new line an \item to an \itemize list (without writing the \item in the .tex-file)
  • Changing the \mycommand to display only text would then finally generate a running text without the need of removing the \item commands.

Any help appreciated.

share|improve this question
The enumitem allows to use so-called “Inline lists”. You still need the \items but you can switch from “Normal” to “Inline” very easily without re-inventing the wheel. –  Qrrbrbirlbel Oct 2 '13 at 16:47
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. –  karlkoeller Oct 2 '13 at 17:17
add comment

1 Answer

up vote 3 down vote accepted

You can profit of xparse and LaTeX3 functions.

\NewDocumentCommand{\outline}{ m o }
  \IfNoValueTF { #2 }
    \par\vspace{\topsep} % no list of items
    \egreg_outline_items:n { #2 } % there are items

\seq_new:N \l_egreg_outline_items_seq
\cs_new_protected:Npn \egreg_outline_items:n #1
  % split the \\ separated list of items
  \seq_set_split:Nnn \l_egreg_outline_items_seq { \\ } { #1 }
  % make an itemize with them
  \seq_map_inline:Nn \l_egreg_outline_items_seq
    \item ##1



\outline{Some text for the outline}

Here is something in the section.


\outline{Here I have more}[
  something \\
  something else \\

Here is something in the section.


enter image description here

share|improve this answer
How about combining this with elements from Most concise way to make list items from each line break to auto \item-ize elements based on line breaks? –  Werner Oct 2 '13 at 18:00
@Werner That's different, because there the items are supposed to be short and here they might span more than one line. –  egreg Oct 2 '13 at 20:53
@Werner That would in fact be the point: The answer from egreg still requires the \\ at the end of each sentence. When generating a final version of the document (running text) the \\ would force a new line for each sentence. –  user258346 Oct 4 '13 at 9:01
@user258346 In a final version you can change the definition of \egreg_outline_items:n to do what you want with the various \\-separated items. That's the advantage of marking up the document; an end of line instead of \\ wouldn't be as good, because editor programs sometimes have strange ideas about what to do with long lines. Exchanging the document with a coworker or your supervisor could break the line divisions. –  egreg Oct 4 '13 at 9:06
I run into problems when trying to make it run with pdflatex on ubuntu 12.04. Including \usepackage{expl3} did not help: ! Undefined control sequence. \egreg_outline_items:n #1->\seq_set_split:Nnn \l_egreg_outline_items_seq {\\... l.45 ] –  user258346 Oct 4 '13 at 9:50
show 1 more comment

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.