10

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?

1 Answer 1

9

\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

1
  • Is that topset or topsep?
    – Matifou
    Commented Jun 30, 2019 at 23:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .