TransWikia.com

line break in tabularx environment

TeX - LaTeX Asked on June 23, 2021

I have a complicated table with multicolumns that overflow. I believe I can’t use seqsplit because it’s a tabular environment (inside a tabularx). I tried newline and hline but it didn’t work either.

documentclass{article}
usepackage{tabularx, seqsplit}
usepackage{multirow}
usepackage{booktabs}

begin{document}

begin{table}[h!]
    centering
begin{tabularx}{textwidth}{llX}
hline
     textbf{PCR} & textbf{Template} & textbf{Primers} 
     hline
     textit{#1} & 355. Pdat-1+intron &        begin{tabular}{@{}l@{}}
                   seqsplit{GCCTATTCCAGTATGACCCCTTTGAA}
                   addlinespace
                   AGATACGGGTTTCACTTTTTCTACCGGTACCCTCCAAGG
                 end{tabular}
    hline
     textit{#2} & 399.Pdat-1::SEC-24.2::mKate::UTR & begin{tabular}{@{}l@{}}
                   TACCGGTAGAAAAAGTGAAACCCGTATCTCAAATCCCAAATGG
                   addlinespace
                   TTTGGATCAACATGAGCATTCGGATTCGC
                 end{tabular} 
                 
         hline
         textit{Fusion} & Products from PCR#1 and #2 & begin{tabular}{@{}l@{}}
                   GCCTATTCCAGTATGACCCCTTTGAA
                   addlinespace
                   TTTGGATCAACATGAGCATTCGGATTCGC
                 end{tabular} 
                 
         hline
end{tabularx}
caption{Primers}
label{tab:Primers_CSKD}
end{table}

end{document}

this is how my attempt looks like

One Answer

One possible solution is makecell from makecell package.

OFFTOPIC: In my opinion you should try to reduce the space of PCR and Template column to fit the whole primer sequence (most of it) on one line or at least give the orientation (5´-3´ end).

documentclass{article}
usepackage{tabularx,seqsplit}
usepackage{multirow}
usepackage{makecell}
usepackage{booktabs}

begin{document}

renewcommand{arraystretch}{2}

begin{table}[h!]
    centering
begin{tabularx}{textwidth}{@{} llX @{}}
hline
     textbf{PCR} & textbf{Template} & textbf{Primers} 
     hline
     textit{#1} & 355. Pdat-1+intron &        begin{tabular}{@{}l@{}}
                   makecell[l]{GCCTATTCCAGTATGACCCCTTTGAA}
                   addlinespace
                   makecell[l]{AGATACGGGTTTCACTTTTTCTACCGGTACCCTCCAAGG}
                 end{tabular}
    hline
     textit{#2} & 399.Pdat-1::SEC-24.2::mKate::UTR & begin{tabular}{@{}l@{}}
                   makecell[l]{TACCGGTAGAAAAAGTGAAACCCGTATCTCAAATCCCAAATGG}
                   addlinespace
                   makecell[l]{TTTGGATCAACATGAGCATTCGGATTCGC}
                 end{tabular} 
                 
         hline
         textit{Fusion} & Products from PCR#1 and #2 & begin{tabular}{@{}l@{}}
                   makecell[l]{GCCTATTCCAGTATGACCCCTTTGAA} 
                   addlinespace
                   makecell[l]{TTTGGATCAACATGAGCATTCGGATTCGC} 
                 end{tabular} 
                 
         hline
end{tabularx}
caption{Primers}
label{tab:Primers_CSKD}
end{table}

end{document}

enter image description here

Correct answer by Roland on June 23, 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