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 am preparing questionnaire template in LaTeX.

I have the following code (simplified):

\documentclass{article}
\begin{document}
\framebox{\parbox{4cm}{
    \textbf{3. How often do you have a headache?}\\
    \textit{(Choose one option)}\begin{flushright}
        never 0

        seldom 1

        often 2
    \end{flushright}            
}}
\end{document}

Output looks like this:

enter image description here

My questions are:

  • Why I get the blank lines(marked by red color on picture for convenience) before and after the flushright environment ?
  • How to remove them?
share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

\flushright and \flushleft are defined using \trivlist:

\def\flushright{\trivlist \raggedleft\item\relax}
\def\endflushleft{\endtrivlist}

and this adds some additional vertical space. If you don't want this additional space. you could use the \raggedleft, \raggedright commands instead of the \flushright, \flushleft environments. Another option would be to set \topset (and \parskip, and \partopset, if necessary) to 0pt:

\documentclass{article}
\begin{document}

\framebox{\parbox{4cm}{
    \textbf{3. How often do you have a headache?}\\
    \textit{(Choose one option)}\begin{flushright}
        never 0

        seldom 1

        often 2
    \end{flushright}            
}}

\framebox{\parbox{4cm}{\setlength\topsep{0pt}
    \textbf{3. How often do you have a headache?}\\
    \textit{(Choose one option)}\begin{flushright}
        never 0

        seldom 1

        often 2
    \end{flushright}            
}}


\framebox{\parbox{4cm}{
    \textbf{3. How often do you have a headache?}\\
    \textit{(Choose one option)}

\begingroup\raggedleft
        never 0

        seldom 1

        often 2\par
    \endgroup
}}

\end{document}

enter image description here

share|improve this answer
add comment

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.