# An environment with custom justification

I would like to create an environment called "question" with one argument (being the question number) with a certain alignment/justification. How might I define one so that it comes out like how it does in one of the two ways here?

In the linked example, it is just the alignments that I am talking about (not the fonts, sizing, etc.).
There are two kinds of alignments here:

• One is like #5.66 where the question's body is in line with the end of "5.66".
• The other kind, like in #5.64, has the bodies of the questions (i),(ii), etc. in line with lettering, which is itself further right of the question number.

In each case how might I phrase my environment's definition?

-
Are you talking about the "5.64" or "(i)"? The first seems like a job for \marginnote, the latter for a list environment – Qrrbrbirlbel Sep 19 '12 at 19:01
Good question. It's been updated. – JSeaton Sep 19 '12 at 19:09

This style of alignment is usually done with a list. And, in the world of lists, enumitem is king. Here's a short example of how this can be obtained (without much formatting):

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{enumitem}% http://ctan.org/pkg/enumitem
\begin{document}
\begin{enumerate}[labelwidth=4em,labelsep=1em]
\item[5.64] \lipsum[2]
\item[5.66] Some short text
\item[5.89] \lipsum[2]
\end{enumerate}
\end{document}​


Of course, with enumitem you can make these settings locally (as I did in my example) via an optional argument [...], or globally using \setlist. See the enumitem documentation for more information/detail.

Also, since it manages lists, the numbering is easily automated. In my example above, the numbering can be supplied manually using \item[...], or in an automated fashion without the optional argument to \item.

Nesting is also possible using the same approach:

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{enumitem}% http://ctan.org/pkg/enumitem
\begin{document}
\begin{enumerate}[labelwidth=4em,labelsep=1em]
\item[5.64] \lipsum[2]
\item[5.66] Some short text
\begin{enumerate}[label=(\roman*),labelwidth=2em,labelsep=.5em]
\item Here is some text
\item Here is some text
\item Here is some text
\end{enumerate}
\item[5.89] \lipsum[2]
\end{enumerate}
\end{document}​

-
Werner: thank you. I actually just edited the question. How would we define the argument in the case of having say question (i) and (ii) a step over from the question number? – JSeaton Sep 19 '12 at 19:11
@JSeaton: I just added some nesting options. Does that answer your question? – Werner Sep 19 '12 at 19:12
For some reason, I've copied and pasted your first bit of code onto a blank tex file and things have come out wonky. For starters, the alignment is very far to the right (and changing those two parameters you gave doesn't do anything). Also, now anything I write above or below the enumerate environment is weirdly justified along with everything in the environment. What has happened? – JSeaton Sep 19 '12 at 19:28
@JSeaton: What version of enumitem do you have? CTAN reports v3.5.2. Add \listfiles before \documentclass and inspect your .log after *File List*. I used ScribTeX which uses TeX Live 2009 with v2.2. However, it should work as-is with the most recent. – Werner Sep 19 '12 at 19:39
I have v3.5.2 as well... I now realise that this is some weird default setting on my end (and this is a problem that has never happened before). I'm using texworks and if I just create a basic article with no formatting, this weird alignment happens on its own... any idea as to what's going on? – JSeaton Sep 19 '12 at 19:50