TransWikia.com

Minipage in table has strange inter-row spacing

TeX - LaTeX Asked on December 4, 2020

I have a pandoc generated latex table (from markdown) which looks like the following:

enter image description here

What I dont get is how to properly space the rows, lets say with 12pt. The tabularnewline[12pt] has no effect? Why doesnt it work?
How can I space the content rows (not the header) correctly?

documentclass{article}

usepackage{longtable, booktabs}

begin{document}

begin{longtable}[]{@{}ll@{}}
caption{TODO Title einfügen}tabularnewline
toprule
begin{minipage}[b]{0.39columnwidth}raggedright
as dasd asd asd strut
end{minipage} & begin{minipage}[b]{0.52columnwidth}raggedright
AA-Modellstrut
end{minipage}tabularnewline
midrule
endfirsthead
toprule
begin{minipage}[b]{0.39columnwidth}raggedright
asd asd asd asd asd strut
end{minipage} & begin{minipage}[b]{0.52columnwidth}raggedright
AA-Modellstrut
end{minipage}tabularnewline
midrule
endhead
begin{minipage}[t]{0.39columnwidth}raggedright
Was ist passiert?strut
end{minipage} & begin{minipage}[t]{0.52columnwidth}raggedright
begin{itemize}
item
  ajkshd kjahsd kjhaskjhdkj haskdjhaklsjdaklsjhd klajshd lkajshd klajshd kahs dlkha sd
end{itemize}
end{minipage}tabularnewline[12pt]
begin{minipage}[t]{0.39columnwidth}raggedright
Wie fühle ich mich? Und du?strut
end{minipage} & begin{minipage}[t]{0.52columnwidth}raggedright
begin{itemize}
item
  ajkshd lkajsd löajks döljasdökjasöldkjasöld aölsdj aölsjd ölasjd ölajs d
end{itemize}
end{minipage}tabularnewline
bottomrule
end{longtable}

end{document}

2 Answers

I wouldn't' use minipages in table, rather use p columns and for itemize list in the second columns rather use enumitem packages and its ability of customizations:

documentclass{article}

usepackage{array,      % new
            booktabs, longtable,
            makecell}   % new
usepackage{enumitem}   % new
usepackage{etoolbox}   % new
AtBeginEnvironment{longtable}{%
setlist[itemize]{nosep=0pt,
                 leftmargin=*,
                 label=textbullet,
                 after=end{minipage},                  % <---
                 before=begin{minipage}[t]{linewidth} % <---
                 }
                      }

begin{document}

begingroup
setcellgapes{2pt}
makegapedcells
    begin{longtable}[]{@{} >{raggedright}p{dimexpr0.45columnwidth-tabcolsep}
                            >{raggedright}p{dimexpr0.55columnwidth-tabcolsep} @{}}
caption{TODO Title einfügen}tabularnewline
    toprule
as dasd asd asd 
    &   AA-Modell       tabularnewline
    midrule
endfirsthead
    toprule
asd asd asd asd asd 
    &   AA-Modell       tabularnewline
    midrule
endhead
%
Was ist passiert? 
    &   begin{itemize}
    item   ajkshd kjahsd kjhaskjhdkj haskdjhaklsjdaklsjhd klajshd lkajshd klajshd kahs dlkha sd
        end{itemize}   tabularnewline
Wie fühle ich mich? Und du?
    &   begin{itemize}
    item   ajkshd lkajsd löajks döljasdökjasöldkjasöld aölsdj aölsjd ölasjd ölajs d
        end{itemize}   tabularnewline
    bottomrule
end{longtable}
endgroup

end{document}

enter image description here

Correct answer by Zarko on December 4, 2020

You wrote,

What I don't get is how to properly space the rows, let's say with 12pt. The tabularnewline[12pt] has no effect?

Assuming that 12pt is a stand-in for baselineskip, you could -- but shouldn't -- replace tabularnewline[12pt] with . That ends up inserting way too much whitespace, though. Since you use the booktabs package, a much better solution is to use addlinespace. I therefore suggest that you replace

tabularnewline[12pt]

with

 addlinespace

A full MWE and its output -- note that I've tried to clean up your somewhat unruly code:

enter image description here

documentclass{article}
usepackage[T1]{fontenc}
usepackage{longtable, booktabs}
usepackage{array} % for 'newcolumntype' macro
newcolumntype{P}[1]{>{raggedrightarraybackslash}p{#1textwidth}}

begin{document}

begin{longtable}{@{} P{0.39} P{0.52} @{}}

% headers and footers:
caption{TODO Title einfügen} 
toprule
as dasd asd asd & AA-Modell 
midrule
endfirsthead

toprule
asd asd asd asd asd AA-Modell 
midrule
endhead

midrule
endfoot

bottomrule
endlastfoot

%% body of longtable:
Was ist passiert? & 
begin{minipage}[t]{hsize} raggedright
  begin{itemize}
  item
    ajkshd kjahsd kjhaskjhdkj haskdjhaklsjdaklsjhd klajshd lkajshd klajshd kahs dlkha sd
  end{itemize}
end{minipage} 
%%           % <-- not good
 addlinespace % <-- much better 

Wie fühle ich mich? Und du? & 
begin{minipage}[t]{hsize} raggedright
  begin{itemize}
  item
    ajkshd lkajsd löajks döljasdökjasöldkjasöld aölsdj aölsjd ölasjd ölajs d strut
  end{itemize}
end{minipage} 

end{longtable}

end{document}

Answered by Mico on December 4, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP