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 result:
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:
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).