1

I have seen several questions like this and the corresponding answers, whereas this is the most promising. However that aligns vertically the top of both lists. I would like each item of the list to align to the corresponding item on the other list, like the first with the first, the second with the second, and so on.

Here is the MWE:

\documentclass[12pt,a4paper]{article}

\usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[ngerman]{babel} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{emoji} %requires compilation with Lua(La)TeX \usepackage{graphicx} \usepackage{array, xltabular,enumitem} \usepackage[left=2.00cm, right=3.00cm, top=1.00cm, bottom=1.00cm, includefoot]{geometry}

% from the answer of Stefan Kottwitz on the linked question \makeatletter \newcolumntype{Y}{>{@minipagetrue}X} \newcolumntype{P}[1]{>{@minipagetrue}p{#1}} \makeatother

\begin{document}

\begin{xltabular}{\textwidth}{| Y | p{1.8cm} | P{5cm} |}
    \hline
    Kompetenz/Inhalt & \emoji{smile}\ \emoji{neutral-face}\ \emoji{frowning-face} & Info und Übungen im LB Fundamente 9\\
    \hline
    \textbf{Dein Fundament}%
    \begin{itemize}
        \item Ich kann lineare Gleichungen (und Gleichungssysteme) lösen.
        \item Ich kann Binomische Formeln nennen und anwenden.
        \item Ich kann lineare Funktionen anhand von Funktions-gleichungen zeichnen bzw. vom Graphen die Funktionsgleichung ablesen.
    \end{itemize} & &%
    \begin{itemize}
        \item S. 48
        \item S. 48
        \item S. 49
    \end{itemize}\\
    \hline
\end{xltabular}

\end{document}

Is there a way to do it?

EDIT:

After trying leandriis' solution, I have this MWE:

\documentclass[12pt,a4paper]{article}

\usepackage{ragged2e} \usepackage{calc} \usepackage[ngerman]{babel} \usepackage{makecell} \usepackage{xltabular} \usepackage[left=2.00cm, right=3.00cm, top=1.00cm, bottom=1.00cm, includefoot]{geometry}

\usepackage{fontawesome5}

\newcommand{\myitem}{\textbullet} \newcommand{\myphantomitem}{\phantom{\textbullet}} \newlength{\hangwidth} \setlength{\hangwidth}{\widthof{\textbullet~~}}

\begin{document} \renewcommand{\arraystretch}{1.5}

\begin{xltabular}{\textwidth}{| >{\hangindent=\hangwidth\RaggedRight\arraybackslash}X | c | >{\RaggedRight\arraybackslash}m{5cm} |}
    \hline
    %        Kompetenz/Inhalt & \emoji{smile} \emoji{neutral-face} \emoji{frowning-face} & Info und Übungen im LB Fundamente 9\\
    Kompetenz/Inhalt & \faSmile[regular]~ \faMeh[regular]~ \faFrown[regular] & Info und Übungen im LB Fundamente 9\\
    \hline
    \textbf{Dein Fundament} & & \\
    \myitem Ich kann lineare Gleichungen (und Gleichungssysteme) lösen.
    & &%
    \myitem S. 48 \\
    \myitem Ich kann Binomische Formeln nennen und anwenden.
    & &%
    \myitem S. 48\\
    \myitem Ich kann lineare Funktionen anhand von Funktionsgleichungen zeichnen bzw. vom Graphen die Funktionsgleichung ablesen.
    & &%
    \myitem S. 49\\
    \hline
    \multicolumn{1}{| >{\RaggedRight\arraybackslash}X |}{\textbf{2.2 Strecken, Stauchen, Spiegeln} $\mathbf{f(x) = ax^2}$} & & \\
    \myitem Ich kann beschreiben, wie sich die Normalparabel in Abhängigkeit vom Parameter a verändert. & & \myitem S. 53\newline \myphantomitem S. 54 Aufg. 1 \\
    \myitem Ich kann Parabeln der Form $f(x) = ax^2$ (auch ohne Wertetabelle) zeichnen. & & \myitem S. 54 Aufg. 2 \\
    \myitem Ich kann zu gegebenen Graphen  Funktionsgleichung zuordnen. & & \myitem S. 54 Aufg. 3+4 \\
    \myitem Ich kann Punkte auf der Parabel bestimmen. & & \myitem S. 54 Aufg. 5+6 \\
    \myitem Ich kann Funktionsgleichung einer quadratischen Funktion aus ihren Eigenschaften aufstellen. & & \myitem S. 55 Aufg. 7-9 \\
    \myitem Ich kann die Form von Parabeln beschreiben und Aussagen dazu treffen. & & \myitem S. 55 Aufg. 10b)c) \\
    \myitem Ich kann fehlende Koordinaten von Punkten rechnerisch bestimmen. & & \myitem S. 56 Aufg. 13+14 \\
    \myitem Ich kann in Anwendungsaufgaben mit Parabeln modellieren. & & \\
    \hline
\end{xltabular}

\end{document}

Now the problem is in the second "block" last column. With a \newline in one of the cells, the bullet doesn't line up with the corresponding bullet in the first column.

output of the second MWE

Andyc
  • 555
  • 1
    What kind of output do you expect? Probably a sketch would help in order to clarify your requirements. As far as I can tell from the code, you should end up with both lists being aligned to the top of their respective cells. Do you instead for example want the third item in both cells to appear at the same vertical position, as for example shown here: https://i.stack.imgur.com/K045H.png? – leandriis Apr 05 '21 at 14:55
  • @leandriis That's exactly what I wanted. Sorry I didn't clarify good enough. Actually, you know what? I'll edit the question to clarify. And yes, I would have been happy to post a sketch, but I don't know how to do it (at least not as nice as yours: I would have to do it by hand). But you nailed it. – Andyc Apr 05 '21 at 15:17

1 Answers1

1

The following might serve as a place to start from. (Due to the lack of a font compatible with the emoji package, I replaced the emojis with the corresponding icons from the fontawesome5 package. Feel free to revert the change.)

enter image description here

\documentclass[12pt,a4paper]{article}

\usepackage{ragged2e} \usepackage{calc} \usepackage[ngerman]{babel} \usepackage{xltabular} \usepackage[left=2.00cm, right=3.00cm, top=1.00cm, bottom=1.00cm, includefoot]{geometry}

\usepackage{fontawesome5}

\newcommand{\myitem}{\textbullet} \newcommand{\myphantomitem}{\phantom{\textbullet}} \newlength{\hangwidth} \setlength{\hangwidth}{\widthof{\textbullet~~}} \usepackage{makecell}

\begin{document} \renewcommand{\arraystretch}{1.5} \begin{xltabular}{\textwidth}{| >{\hangindent=\hangwidth\RaggedRight\arraybackslash}X | c | >{\RaggedRight\arraybackslash}m{5cm} |} \hline % Kompetenz/Inhalt & \emoji{smile} \emoji{neutral-face} \emoji{frowning-face} & Info und Übungen im LB Fundamente 9\ Kompetenz/Inhalt & \faSmile[regular]~ \faMeh[regular]~ \faFrown[regular] & Info und Übungen im LB Fundamente 9\ \hline \textbf{Dein Fundament} & & \ \myitem Ich kann lineare Gleichungen (und Gleichungssysteme) lösen. & &% \myitem S. 48 \ \myitem Ich kann Binomische Formeln nennen und anwenden. \newline \myphantomitem Second part of the same item, does not get its own bullet. & &% \myitem S. 48\ \myitem Ich kann lineare Funktionen anhand von Funktionsgleichungen zeichnen bzw. vom Graphen die Funktionsgleichung ablesen. & &% \myitem S. 49\ \hline \multicolumn{1}{|>{\RaggedRight\arraybackslash}X|}{\textbf{Long text that spans multiple lines and does not need an indentation}} & & \ \myitem Ich kann lineare Gleichungen (und Gleichungssysteme) lösen. & &% \myitem S. 48 \ \myitem Ich kann Binomische Formeln nennen und anwenden. & &% \myitem S. 48\ \myitem Ich kann lineare Funktionen anhand von Funktionsgleichungen zeichnen bzw. vom Graphen die Funktionsgleichung ablesen. & &% \myitem S. 49\ \hline \end{xltabular}

\end{document}


In order to loally remove the hanging indentation, for example from the bold "headers", you can wrap them in a \multicolumn.

leandriis
  • 62,593
  • OK, so instead of using an itemize you write each line in a different cell, which is obviously quick and easy and I kind of like it. However, because this was a MWE, the actual document will be longer (think of a repetition of this "block" with more text to it) and I have the problem that one of the rows in the first column before the itemization (where it now says "Dein Fundament") is long and breaks. With the \hangindent they will get indented too, and unfortunately not in a way that looks nice (the indentation of the width of \textbullet doesn't match anything of the first line). – Andyc Apr 05 '21 at 17:35
  • I sure could have said that in the question, but I was afraid that my MWE wouldn't be so minimal any more. – Andyc Apr 05 '21 at 17:37
  • There's an easy fix for that as well. I updated my answer to include a suggestion for this, as well. – leandriis Apr 05 '21 at 17:56
  • That fixes it indeed. Now just one more minor problem. If one of \myitems has a \newline in it, then it won't line up properly with the first column anymore. I tried to use makecell and break the line with \\\`` instead, but apparentlymakecellandxltabulardon't get along very well (I get aMisplaced \noalignerror). The idea ofmakecellwould be nice to add a padding to all the cells, which would add some spaces between the\myitems as well. Sure there's another way to do that. Or not usexltabularbutlongtable` instead, maybe? – Andyc Apr 05 '21 at 18:53
  • @Andyc: I once again updated my answer to also reflect on items with manual linebreaks as well as on more vertical space between adjacent items. – leandriis Apr 05 '21 at 19:12
  • Thank you for the update, but that doesn't solve my problem. I updated the question with a new MWE to show where the bullets don't line up properly. – Andyc Apr 06 '21 at 08:08
  • 1
    To overcome this alignment issue, use \begin{xltabular}{\textwidth}{| >{\hangindent=\hangwidth\RaggedRight\arraybackslash}X | c | >{\RaggedRight\arraybackslash}p{5cm} |}. As a side effect, you will also loose the vertically centered column headers. If you wish to keep them, use \multicolumn{1}{>{\RaggedRight\arraybackslash}m{5cm}|}{Info und Übungen im LB Fundamente 9} – leandriis Apr 06 '21 at 17:40
  • Sure enough: it works. Thanks! – Andyc Apr 06 '21 at 18:08