Text Formatting ⇒ how would you typeset Q and A?
how would you typeset Q and A?
I have Q&A section with the typical bold Q and bold question then newline and bold A and the answer. I'm a beginner at LaTeX and was wondering if there were a way to separate this formatting better logically? (I mean so that I don't physically apply formatting to every question and answer, but instead use a more abstract Q and A command.) Thank you.
NEW: TikZ book now 40% off at Amazon.com for a short time.
-
- Posts: 37
- Joined: Sun Mar 29, 2009 1:41 am
how would you typeset Q and A?
You probably want to make your own command. Something quick and dirty to get you started:
Code: Select all
\documentclass{article}
\newenvironment{qanda}{\setlength{\parindent}{0pt}}{\bigskip}
\newcommand{\Q}{\bigskip\bfseries Q: }
\newcommand{\A}{\par\textbf{A:} \normalfont}
\begin{document}
The following Q\&A is brought to you by Perfect Tenses Unlimited, Mrs.~Antimony's Electrons, and the Free Falling Bodies' Association of the Pacific Ocean. We thank our partners indomitably.
\begin{qanda}
\Q What is the meaning of life?
\A It is only known by the dancing kangaroos of Tibet and the neutrinos of the sun.
\Q How can I be endimmened?
\A Conquer the world is seventy days. Dislocate the Riemann Hypothesis. Undermine Soviet subjugation involving the juxtaposition of colorless green ideas that sleep furiously. Undeniably, this is the Way. Alternatively, you may turn off the lamp next to you.
\Q What shall I ever do?!? My husband is three more eyelashes than he should! Please help me, Counselor, oh thank ye!
\A Shut thy trap. Fight fiercely, Harvard.
\end{qanda}
This is the very end, thank you very much. May conflagarations prevail!
\end{document}
how would you typeset Q and A?
Thanks man! I'm going to use a version of your environment, but first I want to figure it out a single time, without the environment.
What I have so far is:
where the hspace is a HORRIBLE hack, that doesn't really work! (The Q and A aren't lined up). The reason I have it this way is to have nice automatic numbering in my questions that follows straight from the subsection commands....
Do you have any idea how I could change hspace to be a REAL vertical align between A. and the Q. that begins each subsection title??
Then I could work on getting that into trhe environment you started for me
Thanks again for the good work...
What I have so far is:
Code: Select all
\subsection{Q. Are you serious man?}
\hspace*{2.5em}\textbf{A.} Dead serious. Ask us.
Do you have any idea how I could change hspace to be a REAL vertical align between A. and the Q. that begins each subsection title??
Then I could work on getting that into trhe environment you started for me

Thanks again for the good work...
how would you typeset Q and A?
If you really want the questions to be (sub)sections, you'd probably have to do something like load the titlesec package and play around with the exact spacing the labels. But unless I really wanted these to be sections, I wouldn't do it like that. How I would do it depends on a lot of things: whether these questions and answers were all in the same place, or spaced out over the document, how long each question or answer could get, etc. etc.
Anyway, what about something like this:
Anyway, what about something like this:
Code: Select all
\documentclass{article}
\newcounter{question}
\setcounter{question}{0}
\newcommand{\question}[1]{\item[Q\refstepcounter{question}\thequestion.] \textit{#1}}
\newcommand{\answer}[1]{\item[A\thequestion.] #1}
\begin{document}
\begin{itemize}
\question{What is your favorite color?}
\answer{Blue}
\question{What is your quest?}
\answer{To seek the holy grail.}
\question{What is the air speed velocity of an unladen swallow?}
\answer{I don't know that!}
\end{itemize}
\end{document}
- Attachments
-
- qa.png (7.58 KiB) Viewed 10933 times