# How to start itemize on same line as text?

I've created a new environment called 'Example' like this:

\newenvironment{example}
{\textbf{Example:} \begin{itemize}}
{\end{itemize}}


The environment works fine, but the items are starting after the Example: text. Is it possible to start with the first item on the same line as the Example: text and vertically aline the rest of the items with the first item?

• The question is not clear. Do you want all the bullets horizontally aligned with the first one that is in the same line as “Example”? If this is what you want, I recommend you not to do it. – egreg Nov 30 '13 at 14:11
• @egreg: I'd like to align the bullets vertically. – Jeroen Nov 30 '13 at 14:13

You can do it, but I wouldn't recommend it. Look at the result and judge for yourself.

\documentclass{article}
\usepackage{enumitem}
\usepackage{lipsum} % just for the example

\newlength{\jeroenlen}
\newenvironment{example}
{\settowidth{\jeroenlen}{\textbf{Example:}}%
\begin{description}[leftmargin=\jeroenlen,labelwidth=0pt,labelsep=0pt]
\item[\textbf{Example:}]%
\begin{itemize}[leftmargin=1.5em,labelsep=.5em]}
{\end{itemize}\end{description}}

\begin{document}
\lipsum[2]
\begin{example}
\item Such and such
\item So and so
\item Enough
\end{example}
\lipsum[3]
\end{document}


The enclosing description environment is necessary for avoiding a line break after “Example:”.

• The only problem there, visually, is the bullets. If you take them out, and just have the items with no markers, it would look fine. – crmdgn Dec 2 '13 at 19:45
• @crmdgn I can agree, but that seems what the OP wants. – egreg Dec 2 '13 at 20:50
\documentclass{article}

\newenvironment{example}
{\textbf{Example:}\begin{minipage}[t]{0.8\linewidth}\begin{itemize}}
{\end{itemize}\end{minipage}}

\begin{document}

\begin{example}
\item These are first examples.
\item Second examples.
\item And more.
\end{example}

\end{document}


• What about a page break? – egreg Nov 30 '13 at 14:12

Using enumitem, you also can have a slightly different layout, where the label of the first item (Example •) is centred with respect to the bullets of the following items, which looks better in my opinion. Here's the result:

\documentclass[11pt, a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{enumitem}
\usepackage{lmodern}
\pagestyle{empty}
\parindent = 0pt

\makeatletter%
\newenvironment{examples}{%
\newsavebox{\Exbox}\newlength{\len}%
\sbox{\Exbox}{\textbf{Examples}\enspace\textbullet}\settowidth{\len}{\usebox{\Exbox}}%
\let\olditem\item
\def\item{\if@newlist\olditem\hspace{0.5\len}\else\olditem\fi}
\setlist{before=\renewcommand{\labelitemi}{\if@newlist\makebox[0pt]{\usebox{\Exbox}}\else\textbullet\fi}}
\begin{itemize}[labelwidth =0.5\len,itemindent=!,leftmargin=!]}%
{\end{itemize}}
\makeatother%

\begin{document}
Let’s try  this:
\begin{examples}%
\item very first element of the list,
\item second element,
\item third element.
\end{examples}
\end{document}