Align points with text vertically
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}
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 packagecalc
.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. Theii
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}
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.