GeneralA new env. like description items

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
tufflax
Posts: 12
Joined: Mon Jul 07, 2008 12:34 am

A new env. like description items

Post by tufflax »

Hey!

Let's say I wanted to make a new environment that looks like a description list item, that is, the first line is not indented, but the rest of the lines are. How can I do that?

And, just out of curiosity, could I make an environment that would indent every two lines?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

A new env. like description items

Post by localghost »

Search the forum for the xlist environment. This could be suitable solution for your problem. You can also try customize the standard list environments with enumitem.


Best regards
Thorsten¹
tufflax
Posts: 12
Joined: Mon Jul 07, 2008 12:34 am

Re: A new env. like description items

Post by tufflax »

Thank you for your answer!

Oh, maybe I wasn't clear enough... I dont want to make some kind of list, I want to make an env that looks kind of like a description item, but that has nothing to do with some kind of list.
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

A new env. like description items

Post by phi »

Dou you mean a hanging indent? Try this:

Code: Select all

\parindent=0pt
\hangindent=24pt
\hangafter=1
Text...
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

A new env. like description items

Post by phi »

tufflax wrote:And, just out of curiosity, could I make an environment that would indent every two lines?
Yes, with the \parshape command you can use every possible combination of indentations:

Code: Select all

\newcommand*\AltIndentParShape[2]{%
  \ifnum#1>0 %
    0pt \linewidth \dimexpr(#2) \dimexpr\linewidth-(#2) %
    \expandafter\AltIndentParShape\expandafter{\number\numexpr#1-2}{#2}%
  \fi
}
\newenvironment{AlternatingIndent}[2]{%
  \everypar{\parshape#1 \AltIndentParShape{#1}{#2}}%
}{}
The environment expects two arguments: the number of lines to which it should be applied (if you want it to apply to all lines of each paragraph, just set this to a value that is greater than the number of lines in the largest paragraph inside the environment); and the indentation for lines with even number (can be any dimexpr). For example:

Code: Select all

\begin{AlternatingIndent}{100}{6pt+12pt}
... Text ...
\end{AlternatingIndent}
Post Reply