TeX - LaTeX Asked by Jordie on November 29, 2020
I want to extract this piece of code into an environment
begin{table}[H]
begin{tabularx}{textwidth}{lX}
toprule
textbf{a} & a midrule
textbf{b} & b midrule
textbf{c} & c midrule
textbf{d} & d midrule
textbf{e} &
begin{enumerate}[leftmargin=*,label=arabic*),nosep,after=vspace{-baselineskip},before=vspace{-0.6baselineskip}]
item x
item y
end{enumerate} midrule
textbf{f} & e bottomrule
end{tabularx}
label{tab:table}
end{table}
Wanted usage:
begin{ucbx}{a}{b}{c}{d}{e}
item x
item y
end{ucbx}
I am currently using the xparse
, tabularx
, float
, booktabs
and enumitem
packages:
NewDocumentEnvironment{ucbx}{+m+m+m+m+m}{%
table[H]
tabularx{textwidth}{lX}
toprule
textbf{a} & #1 midrule
textbf{b} & #2 midrule
textbf{c} & #3 midrule
textbf{d} & #4 midrule
textbf{e} &
enumerate[leftmargin=*,label=arabic*),nosep,after=vspace{-baselineskip},before=vspace{-0.6baselineskip}]
}{%
endenumerate midrule
textbf{f} & #5 bottomrule
endtabularx
endtable
}
This code does not produce the wanted output and also throws You can't use relax' after the.
, Misplaced noalign.
, Undefined control sequence.
, misplaced alignment tab character &.
and LaTeX Error: There's no line here to end.
errors.
I am using XeLaTeX
for compilation.
Thank you.
You should not use enumerate
and endenumerate
, but the proper begin{enumerate}
and end{enumerate}
, but this would conflict with tabularx
.
Solution: if you don't plan to have verb
material in the items, you can use the b
argument specifier.
documentclass{article}
usepackage{tabularx,booktabs,enumitem}
NewDocumentEnvironment{ucbx}{+m+m+m+m+m +b}{%
begin{center}
begin{tabularx}{textwidth}{lX}
toprule
textbf{a} & #1 midrule
textbf{b} & #2 midrule
textbf{c} & #3 midrule
textbf{d} & #4 midrule
textbf{e} &
begin{enumerate}[
leftmargin=*,
label=arabic*),
nosep,
after=vspace{-baselineskip},
before=vspace{-0.6baselineskip}
] #6
end{enumerate} midrule
textbf{f} & #5 bottomrule
end{tabularx}
end{center}
}{}
begin{document}
begin{ucbx}{a}{b}{c}{d}{e}
item x
item y
end{ucbx}
end{document}
No need to call table
if you don't have a caption.
Correct answer by egreg on November 29, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP