Text Formatting ⇒ Format for indented questions/answers
Format for indented questions/answers
I am trying to discern the best way to format questions and answers. They MUST look like what I get from a \quote environment, as there is a stylistic connection between the two, except that each question/answer pair must start on a new line, with no blank lines. For instance (the following three lines SHOULD be indented, but I don't know how to indent in this post):
What is the first answer? Here it is.
What is the next answer? This.
What is the third? Right here.
Thus far I've been simply using a \quote environment, but putting \newline after all but the final line. This works fine, except when there is a page break in the middle of the question. Then what happens is that an excessively large space is inserted after the whole series. This is horrible, as the ensuing text is really the continuation of the preceding paragraph.
So: I'm seeking either an alternative way to format the Q/A's or a way to fix my current strategy so that I avoid the extra spacing.
I've been trying to produce a minimal working example of the excess spacing, but have not been successful so far: the issue seems to disappear when I cut out everything but the immediate paragraph and push it down to a pagebreak. However, I have yet to discern what else might be relevant.
Any thoughts are welcome.
What is the first answer? Here it is.
What is the next answer? This.
What is the third? Right here.
Thus far I've been simply using a \quote environment, but putting \newline after all but the final line. This works fine, except when there is a page break in the middle of the question. Then what happens is that an excessively large space is inserted after the whole series. This is horrible, as the ensuing text is really the continuation of the preceding paragraph.
So: I'm seeking either an alternative way to format the Q/A's or a way to fix my current strategy so that I avoid the extra spacing.
I've been trying to produce a minimal working example of the excess spacing, but have not been successful so far: the issue seems to disappear when I cut out everything but the immediate paragraph and push it down to a pagebreak. However, I have yet to discern what else might be relevant.
Any thoughts are welcome.
NEW: TikZ book now 40% off at Amazon.com for a short time.
Format for indented questions/answers
You could try using the quotation environment, which is similar to the quote environment, but with multiple paragraphs, but inside set paragraph indentation to nothing, and then use a paragraph for each question.
Code: Select all
\documentclass{article}
\usepackage{lipsum}% for autogenerating filler text
\newenvironment{qaquote}{\begin{quotation}\hspace*{-1\parindent}\setlength{\parindent}{0em}\relax}{\end{quotation}}
\begin{document}
\lipsum[1]
\begin{quote}
\lipsum[3]
\end{quote}
\lipsum[2]
\begin{qaquote}%
What is your name? Arthur of Camelot.
What is your quest? I seek the holy grail.
What is the air speed of velocity of an unladen swallow? What do you mean, an African or European swallow?
\end{qaquote}
\lipsum[6-7]
\end{document}
Re: Format for indented questions/answers
Thanks. Unfortunately, this doesn't work. If I use this method, and give each question a new paragraph, then there are blank lines between questions. But I need to have the questions on successive lines.
Format for indented questions/answers
It does work. Here is a screenshot of the output:
If it doesn't work for you, then there must be some important difference about your document which you have neglected to mention. Please post a minimal working example showing the problem.
It might be enough to add \setlength{\parskip}{0pt} right before where I have \setlength{\parindent}{0em}, but it's impossible to know without knowing more about your document. See the Post on Avoidable Mistakes.
If it doesn't work for you, then there must be some important difference about your document which you have neglected to mention. Please post a minimal working example showing the problem.
It might be enough to add \setlength{\parskip}{0pt} right before where I have \setlength{\parindent}{0em}, but it's impossible to know without knowing more about your document. See the Post on Avoidable Mistakes.
Re: Format for indented questions/answers
Thanks. I was able to temporarily fix the problem by using \raggedbottom at the start of the paper, an option frabjous noted in another post. I am not entirely satisfied since I don't grasp what is going on, but will try the alternate suggestion.
The problem with posting a minimal working example is that I cannot find one. Or rather, the minimal working example (for me) is a 25 page paper. When I delete seemingly irrelevant text, the problem disappears, and attempts to create the problem from scratch by adding text don't work. I think latex is inserting blank lines based on the overall distribution of text, but I don't know what algorithm it uses so I can't recreate the problematic situation.
The problem with posting a minimal working example is that I cannot find one. Or rather, the minimal working example (for me) is a 25 page paper. When I delete seemingly irrelevant text, the problem disappears, and attempts to create the problem from scratch by adding text don't work. I think latex is inserting blank lines based on the overall distribution of text, but I don't know what algorithm it uses so I can't recreate the problematic situation.
-
- Posts: 37
- Joined: Sun Mar 29, 2009 1:41 am
Re: Format for indented questions/answers
If I understand the problem correctly, the business with the large spaces (which are not blank lines, if I'm not mistaken) and the fix with \raggedbottom is this: on every page, TeX automatically tries make the text line up flush to the bottom margin at the bottom of the main textblock, so that the letters on each page all sort of fit in exactly the same rectangles. It's the vertical equivalent of justified lines. When justifying lines, TeX puts the appropriate amount of space between words. Since there are a lot of words, the space adjustments aren't that conspicuous. But when aligning the whole page vertically, before and after your quote environments are some of the only places where it would be acceptable to add the vertical space necessary to have the bottoms of the text line up on each page. So these vertical adjustments are often more noticeable. \raggedbottom tells TeX to forget about making the pages have even bottoms, so that no vertical space is added (or subtracted) between lines, section headings, quote environments, etc. It's the vertical equivalent of \raggedright.
Re: Format for indented questions/answers
I would guess that even without using \raggedbottom, the suggestion I made earlier about adding \setlength{\parskip}{0pt} in the definition of the environment should help, since then the space between paragraphs inside that environment would not be rubber lengths and would not stretch to fill out the page.
-
- Posts: 274
- Joined: Fri Feb 05, 2010 10:15 pm
Format for indented questions/answers
I would use the exam class if you are looking for good questions and answering formatting. It is unrivaled by anything else I have used to make Q/A type questions. I love it. Check out the manual.