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'm using the verse package to typeset poems inside a tabular environment. Is it possible to eliminate the space before and after the verse package?

\usepackage{verse}
...
\begin{tabular}{p{30mm} | p{30mm} | p{30mm}}
  \hline
    1.
  &
\begin{verse}
AAAA \\
BBBB \\
CCCC
\end{verse}
  & QUESTION \\ \hline
\end{tabular}

output of MWE

I could manually insert vertical space before and after the verse environment,

\vspace{-\baselineskip}
\vspace{-2.6pt}

but this seems to be an ugly solution. There should be a more elegant solution!

share|improve this question

1 Answer 1

up vote 3 down vote accepted

As the verse environment is based upon the basic list environment, the \compress part of another answer is valid here, too.

But there's still space added after the verse environment, that's why I subtract an additional length of \lastskip and \baselineskip at the end (one \baselineskip because the verse environment acts as an paragraph and you could actually begin another one on the next line) which adds up to 2\baselineskip.

This solution is still “ugly” as it is needed to type \compress as well as \vspace{-2\baselineskip} every time, so I defined a new environment, called tvserse.

A third (localized) solution is the definition of a new column type V that takes two (mandatory) arguments:

  1. the actual optional argument for the verse environment (use {} for the non-usage of this argment), and
  2. the width of the underlying p column.

The whole cell is now typeset as a verse.

If the array package is used an additional \leavevmode is needed in the first two cases.

Code

\documentclass{article}
\usepackage{verse}
\usepackage{array}
\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother
\newenvironment{tverse}[1][]{\compress\ifx\\#1\\\begin{verse}\else\begin{verse}[#1]\fi}{\end{verse}\vspace{-\lastskip}\vspace{-\baselineskip}\leavevmode}
\newcolumntype{V}[2]{%
    >{%
        \compress%
        \ifx\\#1\\%
            \begin{verse}%
        \else%
            \verse[#1]%
        \fi%
    }%
    p{#2}%
    <{%
        \end{verse}%
        \vspace{-\lastskip}%
        \vspace{-\baselineskip}%
    }%
}
\begin{document}
\begin{tabular}{p{30mm} | p{30mm} | p{30mm}}
  \hline 1. & \compress \begin{verse} AAAA \\
                                      BBBB \\
                                      CCCC \end{verse} \vspace{-\lastskip}\vspace{-\baselineskip}\leavevmode & QUESTION \\ \hline
\end{tabular}

\begin{tabular}{p{30mm} | p{30mm} | p{30mm}}
  \hline 1. & \begin{tverse} AAAA \\
                             BBBB \\
                             CCCC \end{tverse} & QUESTION \\ \hline
\end{tabular}

\begin{tabular}{p{30mm} | V{}{30mm} | p{30mm}}
  \hline 1. &  AAAA \\
               BBBB \\
               CCCC & QUESTION \\ \hline
\end{tabular}
\end{document}

Output

enter image description here

share|improve this answer
    
Thank you, your suggestion works! However, the output doesn't match what I see from compiling the code: I see some space at the end of the verse environment. Maybe you should change the output image so that it is correct? –  I Like to Code Nov 19 '12 at 3:27
    
@user856624 Yes, that was a confusion on my side. I've added a third solution to my answer and updated code and output image as well. –  Qrrbrbirlbel Nov 19 '12 at 3:37

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.