Align points with text vertically

I have the following code:

 \begin{itemize}
\item SPOJ - everyone loves SPOJ\\
- I love SPOJ
\end{itemize}


And what I'd like to do is display the two hyphens at the same position.

I'd love something as simple as possible, such as:

 \begin{itemize}
\item SPOJ &- everyone loves SPOJ\\
&- I love SPOJ
\end{itemize}


Which doesn't work. However, all solutions are welcome.

I've searched for it but haven't found anything that would work (maybe because of my ignorance with LaTeX and inability to use some solutions in my case).

I'll add that I know what I'm interested in and itemize inside itemize won't satisfy me. Sorry for being so demanding.

Thanks to egreg's tip on \linewidth (not \textwidth), this approach will now handle wrapping, if your required text grows wider (however, the wrapped text will not be indented with respect to the hyphen).

I then provide a second way with nested itemize environments. That doesn't look exactly like what you requested, but you may find it acceptable.

\documentclass{article}
\usepackage{calc}
\begin{document}
\begin{itemize}
\item SPOJ \parbox[t]{\linewidth-\widthof{SPOJ }}{%
- everyone loves SPOJ\\
- I love SPOJ}
\end{itemize}

Alternate way:

\begin{itemize}
\item SPOJ \begin{itemize}
\item everyone loves SPOJ
\item I love SPOJ
\end{itemize}
\item What is SPOJ?
\end{itemize}
\end{document}


• \parbox[t]{\linewidth-\widthof{SPOJ }} with calc ;-) Sep 12, 2013 at 20:26
• @egreg I was trying \textwidth and it wasn't enough. I'll revise. Sep 12, 2013 at 20:33

An alternative solution using tabularx and an X column for the text:

• The calculation of the width can be done with package calc as shown in egreg's comment:

\begin{tabularx}{\linewidth-\widthof{TeX.SX }}


The example uses \settowidth and e-TeX's \dimexpr to provide an alternative for package calc.

• The itemize symbol for the next level is \textendash in bold. That is a little more present than a small hyphen symbol. Therefore \labelitemii is used. The ii at the end is the roman number for the list depth (2).

\documentclass{article}
\usepackage{tabularx}
\usepackage{array}

\newlength\testlength

\begin{document}
\begin{itemize}
\item \TeX.SX
\settowidth{\testlength}{\TeX.SX }%
\begin{tabularx}{\dimexpr\linewidth-\testlength\relax}[t]
{@{}>{\labelitemii}l@{ }X@{}}
& everyone loves \TeX.SX\\
& I love \TeX.SX
\end{tabularx}%
\end{itemize}
\end{document}


With package linegoal it simplifies to:

\documentclass{article}
\usepackage{tabularx}
\usepackage{array}
\usepackage{linegoal}

\begin{document}
\begin{itemize}
\item \TeX.SX
\begin{tabularx}{\linegoal}[t]
{@{}>{\labelitemii}l@{ }X@{}}
& everyone loves \TeX.SX\\
& I love \TeX.SX
\end{tabularx}%
\end{itemize}
\end{document}

• You can also load linegoal package and use \begin{tabularx}{\linegoal}[t]. Sep 13, 2013 at 9:58
• @karlkoeller: Thanks, I have added a simplified version using package linegoal. Sep 13, 2013 at 11:12

The following uses the powerful enumitem package in order to provide an itemize-like environment that allows for breaking across the page boundary if needed:

\documentclass{article}
\usepackage{enumitem}% http://ctan.org/pkg/enumitem
\begin{document}
Some text before
\begin{description}[font={\normalfont\textbullet\ },leftmargin=1cm,style=nextline]
\item[SPOJ] - everyone loves SPOJ \\
- I love SPOJ
\end{description}
Some text after
\end{document}


The hard-coded 15mm left margin could be made "softer" using elements from the other posts to calculate the width, or use the widest key-value.

• +1 it's almost always better to use a list rather than box or table, it is far more flexible, allowing stretchy vertical space and page breaking within the item. Sep 12, 2013 at 21:10
• @DavidCarlisle Noted for future reference... Sep 13, 2013 at 22:12