Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I apologize if this is a basic question, but I'm new to LaTeX and typography in general, and I'm not sure how to articulate my question properly.

I have a document which looks like this:

\documentclass[12pt,letterpaper]{article}
    \usepackage[margin=0.7in]{geometry}
    \usepackage[parfill]{parskip}

    \newenvironment{question}[1]
    {\par\bfseries#1.\ignorespaces}
    {\par\ignorespacesafterend}

    \newenvironment{answer}
    {\par\leftskip=2.0em\ignorespaces}
    {\par\ignorespacesafterend}
\begin{document}

\begin{question}{1}
Testing testing testing testing testing testing testing testing testing 
Testing testing testing testing testing testing testing testing testing 
Testing testing testing testing testing testing testing testing testing 

Testing testing testing testing testing testing testing testing testing 
Testing testing testing testing testing testing testing testing testing 
\end{question}
\begin{answer}
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
\end{answer}

\begin{question}{3}
Test test
\end{question}
\begin{answer}
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
\end{answer}

\end{document}

broken

How do I modify my question environment so that the very first line after the number is indented to the same level the text inside the answer environment is? I don't want the number to be indented, but I do want the line following it (but not subsequent lines) to be indented to the same level as the lorem ipsum text.

As an addendum, I was only able to describe my problem with the help of a picture. What's the proper way to explain it by using words?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You can place the number inside a box of the desired width:

\documentclass[12pt,letterpaper]{article}
    \usepackage[margin=0.7in]{geometry}
    \usepackage[parfill]{parskip}

\newlength\ansindent
\setlength\ansindent{2em}

    \newenvironment{question}[1]
    {\par\bfseries\makebox[\ansindent][l]{#1.}\ignorespaces}
    {\par\ignorespacesafterend}

    \newenvironment{answer}
    {\par\leftskip=\ansindent}
    {\par\ignorespacesafterend}
\begin{document}

\begin{question}{1}
Testing testing testing testing testing testing testing testing testing 
Testing testing testing testing testing testing testing testing testing 
Testing testing testing testing testing testing testing testing testing 

Testing testing testing testing testing testing testing testing testing 
Testing testing testing testing testing testing testing testing testing 
\end{question}
\begin{answer}
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
\end{answer}

\begin{question}{3}
Test test
\end{question}
\begin{answer}
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
\end{answer}

\end{document}

enter image description here

share|improve this answer
    
Ah, almost! Sorry, I didn't explain very clearly. How would I modify parshape so that the line immediately to the right of the number is indented? I want all the lines below the number to be aligned to the left normally. –  Michael0x2a Nov 4 '12 at 2:44
    
@Michael0x2a ah, I see. I updated my answer (no need for \parshape now). Please let me know if something like this is what you want. –  Gonzalo Medina Nov 4 '12 at 2:49
    
That's exactly it! Thanks! –  Michael0x2a Nov 4 '12 at 2:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.