Text Formatting ⇒ Alignment over two lists
- svend_tveskaeg
- Posts: 478
- Joined: Sun Jul 12, 2009 5:31 am
Re: Alignment over two lists
I cannot figure out the problem, but I have accepted your answer anyway.
Thank you for your help.
Thank you for your help.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
-- Zapp Brannigan, Futurama (season 1, episode 4)
NEW: TikZ book now 40% off at Amazon.com for a short time.

- svend_tveskaeg
- Posts: 478
- Joined: Sun Jul 12, 2009 5:31 am
Re: Alignment over two lists
Hmmm! Something was wrong with the file. When I deleted it (again!) and startet with a new one, it complies just fine.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
-- Zapp Brannigan, Futurama (season 1, episode 4)
- svend_tveskaeg
- Posts: 478
- Joined: Sun Jul 12, 2009 5:31 am
Alignment over two lists
The code worked just as I wanted; thank you!
Now I have another request: Is it possible to `restart' the counter for the question or answer from (1) every time I begin a new enviroment?
Thank you in advance, again.
Now I have another request: Is it possible to `restart' the counter for the question or answer from (1) every time I begin a new enviroment?
Thank you in advance, again.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
-- Zapp Brannigan, Futurama (season 1, episode 4)
Alignment over two lists
Oh, I forgot that
at the beginning of the definition of the
Regards
\stepcounter
acts globally! It's easy: add
Code: Select all
\setcounter{question}{0}%
question
environment (completely analogous for the answer
environment).Regards
site moderator & package author
- svend_tveskaeg
- Posts: 478
- Joined: Sun Jul 12, 2009 5:31 am
Alignment over two lists
This is getting a bit embarrassing for me.
The following code will not compile, even though I think that I have inserted \setcounter at the beginning of the question and answer enviroments.
What is wrong?
The following code will not compile, even though I think that I have inserted \setcounter at the beginning of the question and answer enviroments.

Code: Select all
\documentclass[danish]{article}
\usepackage{babel,enumitem}
\usepackage{lipsum}% for dummy text
\newlength\mylabelwidth
\setlength\mylabelwidth{6em}
\makeatletter
\newlength\my@labelindent
\setlength\my@labelindent{0pt}
\newcommand*\mylabelindent{\noindent\hspace*{\my@labelindent}}
\makeatother
\newcounter{question}
\newenvironment{questions}
\setcounter{question}{0}%
{%
\def\Item{%
\stepcounter{question}%
\par\mylabelindent
\parbox{\mylabelwidth}{Q~(\arabic{question}):}}%
\vskip0pt\relax\addvspace{\baselineskip}% skip before the env
}%
{\par\noindent\vskip0pt\relax\addvspace{\baselineskip}}% skip after the env
\newcounter{answer}
\newenvironment{answers}
\setcounter{answer}{0}%
{%
\def\Item{%
\stepcounter{answer}%
\par\mylabelindent
\parbox{\mylabelwidth}{Answer~(\arabic{answer}):}}%
\vskip0pt\relax\addvspace{\baselineskip}%
}%
{\par\noindent\vskip0pt\relax\addvspace{\baselineskip}}
\begin{document}
Wierd animal features:
\begin{questions}
\Item Why is a horse not blue? \lipsum[4]
\Item Why can a goat not fly?
\end{questions}
Explanations:
\begin{answers}
\Item It would look stupid.
\Item I actually have seen a flying goat.
\end{answers}
\end{document}
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
-- Zapp Brannigan, Futurama (season 1, episode 4)
Alignment over two lists
You need to insert it after the opening brace of
\newenvironment
's second argument.site moderator & package author
- svend_tveskaeg
- Posts: 478
- Joined: Sun Jul 12, 2009 5:31 am
Re: Alignment over two lists
Spot on. Thank you very much.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
-- Zapp Brannigan, Futurama (season 1, episode 4)