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.

Following this question: I want to create an environment for a table with the following specifications:

The left column is a vertically centered rotated text, saying Övning. The right column contains paragraphs of text, so I want an empty line for each paragraph (as if I'm using \usepackage[parfill]{parskip}) and \\ to just give me a line break.

The previous question fixed the paragraph issue but broke the centering for the left column. Also, if I use line breaks

Here's my environment now:

\usepackage{array}
\usepackage{rotating}

\newcolumntype{P}[1]{>{%
  \parskip=0.5\baselineskip%
  \advance\parskip by 0pt plus 2pt
   \setlength{\parfillskip}{30pt plus 1fil}}p{#1}}

\newenvironment{exercise}[1]
{
    \begin{tabular}{m{0.05\textwidth}|P{0.85\textwidth}}   # using m in the second column gives back the vertical centering
    \rotatebox{90}{\textbf{Övning}} & \textbf{#1}
}
{\end{tabular}
\bigskip
}

I can use it like so:

\begin{exercise}{5.7}
Övningen finns under Warmup-1 $\rightarrow$ makes10.

Du är given två heltal, \texttt{a} och \texttt{b} som parametrar. Skriv en funktion som returnerar \texttt{True} om ett av talen är 10 eller om summan av dem är 10.

\texttt{makes10(9, 10)} $\rightarrow$ \texttt{True}

\texttt{makes10(9, 9)}  $\rightarrow$ \texttt{False}

\texttt{makes10(1, 9)}  $\rightarrow$ \texttt{True}
\end{exercise}

This produces the following resultenter image description here:

However, if I introduce line breaks, like so:

\texttt{makes10(9, 10)} $\rightarrow$ \texttt{True} \\
\texttt{makes10(9, 9)}  $\rightarrow$ \texttt{False} \\
\texttt{makes10(1, 9)}  $\rightarrow$ \texttt{True} \\

Then it breaks my table:

enter image description here

So, I want to be able to use line/paragraph breaks in the right column as usual and I want the text in the vertical column to be centered.

I'm using xelatex with polyglossia (this caused an issue in the previous question).

share|improve this question

1 Answer 1

up vote 3 down vote accepted

\\ ends the current row. With \newline instead of \\ it works as expected.

For vertical centering, use an m column also in your own definition:

\newcolumntype{M}[1]{>{%
  \parskip=0.5\baselineskip%
  \advance\parskip by 0pt plus 2pt
   \setlength{\parfillskip}{30pt plus 1fil}}m{#1}}
share|improve this answer
    
Thank you so much! Accepted. –  pg-robban Aug 28 '11 at 16:17

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.