TransWikia.com

Is it possible to get this text to line up horizontally in a table when only one column is using enumerate?

TeX - LaTeX Asked by wazzle on January 21, 2021

I would like to use a table for a heading column and a text column that would be a enumerated list. However, it seems like when I begin the list it automatically starts a new horizontal line for the list text. Can this be aligned to the heading column text? Below is some code that I have tried and the compiled result…

documentclass{article}
usepackage{enumitem}
usepackage[left=1in, right=1in, bottom=0.7in, top=0.7in]{geometry}

begin{document}

begin{tabular}{ p{1in} p{5in} } 
 Top left cell & begin{enumerate}[itemindent=-20pt]
     item Is it possible to get this text to line up horizontally with the top left cell when using enumerate?
     item Thank you!
 end{enumerate}  
end{tabular}

end{document}

enter image description here

2 Answers

enter image description here

 documentclass{article}
usepackage{enumitem}
usepackage[left=1in, right=1in, bottom=0.7in, top=0.7in]{geometry}

begin{document}

begin{tabular}{ p{1in} p{5in} } 
begin{enumerate}[wide=0pt]item[] Top left cellend{enumerate} & begin{enumerate}[]
     item Is it possible to get this text to line up horizontally with the top left cell when using enumerate?
     item Thank you!
 end{enumerate}  
end{tabular}

end{document}

Answered by js bibra on January 21, 2021

Welcome to TeX.SE community!

One of possible solution is to enclose enumerate list in a minipage. This can be done by using enumitem package option before and after:

documentclass{article}
usepackage[hmargin=1in, vmargin=0.7in]{geometry}
usepackage{enumitem}
usepackage{etoolbox}
AtBeginEnvironment{tabular}{% this will have effect in each tabular
    setlist[enumerate]{before=begin{minipage}[t]{linewidth}, % <---
                        after =end{minipage}                   % <---
                        }   }

begin{document}

begin{tabular}{ p{1in} p{5in} }
 Top left cell & begin{enumerate}
     item Is it possible to get this text to line up horizontally with the top left cell when using enumerate?
     item Thank you!
 end{enumerate} 
end{tabular}

end{document}

enter image description here

Addendum: Alternative possibilities is extend column specification p{...} with minipages:

documentclass{article}
usepackage[hmargin=1in, vmargin=0.7in]{geometry}
usepackage{array}
usepackage{enumitem}

begin{document}

begin{tabular}{ p{1in} >{csname @minipagetrueendcsname}p{5in} } % <---
 Top left cell      & begin{enumerate}
                 item Is it possible to get this text to line up horizontally with the top left cell when using enumerate?
                 item Thank you!
                    end{enumerate} 
end{tabular}

end{document}

RCompilation result is the same as before.

Answered by Zarko on January 21, 2021

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