0

I try to do an enumeration / line break in my chart but I am not able to do it. Could you help me to find the right tool?

For the row Advantages I try to get no genomic integration (no frameshift, or even worse damage to the genome) => linebreak high flexibility

And for row cultured cells i try to enumerate the following 3 words: electroporation / lipofection / microinjection

Thank you

% page setup 
\documentclass[a4paper, 11pt]{article}
\usepackage[left=3cm,top=3cm,right=3cm]{geometry}
\usepackage{fancyvrb} 

% tables
\usepackage{booktabs} 
\usepackage{tabularx} 
\newcolumntype{C}{>{\Centering}X}
\newcolumntype{P}[1]{>{\RaggedRight\hspace{0pt}}m{#1}}

\begin{document}

\begin{table}[ht]
\scriptsize
\newlength\colwidth 
\settowidth\colwidth{30\% acrylamide stock solution30\%} % set width of 1st col.
\begin{tabularx}{\textwidth}{@{} P{\colwidth} *{2}{C} @{}}
    \toprule
& Transient transfection & Stable transfection\\
    \midrule
Advantages
    & no genomic integration (no frameshift, or even worse damage to the genome) high flexibility & \\
\addlinespace
cultured cells
    & electroporation / lipofection / microinjection\\
\bottomrule
\end{tabularx}
\endtabularx
\end{table}

\end{document}



5
  • 1
    It looks like you still need to load the ragged2e package for the code to compile.
    – Mico
    Commented Dec 8, 2020 at 21:04
  • 1
    You mention "enumerate" but there is no enumerate in your code example. Also, there's a trailing \endtabularx without an accompanying \tabularx before it... why is that?
    – Werner
    Commented Dec 8, 2020 at 21:04
  • My goal would be to enumerate the key words in the table
    – Elia
    Commented Dec 8, 2020 at 22:31
  • @Elia: What do you mean by "the key words"? Can you provide a complete, example of what you're after?
    – Werner
    Commented Dec 8, 2020 at 23:02
  • I tried to make it more clear in my question
    – Elia
    Commented Dec 9, 2020 at 5:11

2 Answers 2

1

Two examples for use itemize and enumerate in your table and one example with different table design:

\documentclass[a4paper, 11pt]{article}
\usepackage[margin=3cm]{geometry}
\usepackage{fancyvrb}

% tables
\usepackage{ragged2e}   % <--- added
\usepackage{booktabs, tabularx}
\newcolumntype{C}{>{\Centering}X}
\newcolumntype{L}{>{\RaggedRight\hspace{0pt}}X} % <--- new, for the last example
\newcolumntype{P}[1]{>{\RaggedRight\hspace{0pt}}m{#1}}
\newlength\colwidth

\usepackage{enumitem}   % <--- new, for lists (in table)
\usepackage{etoolbox}   % <--- new, for customization of lists used in tables
\AtBeginEnvironment{table}{%
\setlist[itemize]{nosep,
                 leftmargin=*,
                 label=\textbullet, % <---
                 before=\begin{minipage}[t]{\linewidth}, 
                 after=\end{minipage}}                   

\setlist[enumerate]{nosep,
                 leftmargin=*,
                 label=\arabic*.,   % <---
                 before=\begin{minipage}[t]{\linewidth},  
                 after=\end{minipage}}                   
                        }

\begin{document}
With \verb+itemize+
    \begin{table}[ht]
\settowidth\colwidth{30\% acrylamide stock solution30\%} % set width of 1st col.
%
\begin{tabularx}{\textwidth}{@{} P{\colwidth} *{2}{C} @{}}
    \toprule
    & Transient transfection & Stable transfection  \\
    \midrule
Advantages
    &   \begin{itemize}
    \item   no genomic integration (no frameshift, or even worse damage to the genome) 
    \item   high flexibility 
        \end{itemize}   &   \\
\addlinespace
cultured cells
    &   \begin{itemize}
    \item   electroporation 
    \item   lipofection 
    \item    microinjection
        \end{itemize}   &   \\
\bottomrule
\end{tabularx}
    \end{table}
    
or with \verb+enumerate+:

    \begin{table}[ht]
\settowidth\colwidth{30\% acrylamide stock solution30\%} % set width of 1st col.
%
\begin{tabularx}{\textwidth}{@{} P{\colwidth} *{2}{C} @{}}
    \toprule
    & Transient transfection & Stable transfection  \\
    \midrule
Advantages
    &   \begin{enumerate}
    \item   no genomic integration (no frameshift, or even worse damage to the genome)
    \item   high flexibility
        \end{enumerate}   &   \\
\addlinespace
cultured cells
    &   \begin{enumerate}
    \item   electroporation
    \item   lipofection
    \item   microinjection
        \end{enumerate}   &   \\
\bottomrule
\end{tabularx}
    \end{table}
    
or with \verb+l+ and \verb+L+ types of table columns and \verb+enumerate+:

    \begin{table}[ht]
\begin{tabularx}{\textwidth}{@{} l *{2}{L} @{}}
    \toprule
    & Transient transfection & Stable transfection  \\
    \midrule
Advantages
    &   \begin{enumerate}
    \item   no genomic integration (no frameshift, or even worse damage to the genome)
    \item   high flexibility
        \end{enumerate}   &   \\
\addlinespace
cultured cells
    &   \begin{enumerate}
    \item   electroporation
    \item   lipofection
    \item   microinjection
        \end{enumerate}   &   \\
\bottomrule
\end{tabularx}
    \end{table}
\end{document}

enter image description here

Addendum: In a case that you like to have only line breaks. IN such a cases you not need enumitem and etoolbox` packages:

\documentclass[a4paper, 11pt]{article}
\usepackage[margin=3cm]{geometry}
\usepackage{fancyvrb}

% tables
\usepackage{ragged2e}   % <--- added
\usepackage{booktabs, tabularx}
\newcolumntype{L}{>{\RaggedRight\hspace{0pt}}X} % <--- new, for the last example

\begin{document}
...

This you can achieve on three ways:

  • insert empty lines where you like to break cell's content:
Advantages
    &   no genomic integration (no frameshift, or even worse damage to the genome)

        high flexibility
        &   \\
  • use command `verb+\linebreak+
Advantages
    &   no genomic integration (no frameshift, or even worse damage to the genome)\linebreak
        high flexibility
        &   \\
  • or use of command \par
Advantages
    &   no genomic integration (no frameshift, or even worse damage to the genome)\par
        high flexibility
        &   \\

In all above cases the result is the same:

enter image description here

1
  • Thank you very much! That is amazing
    – Elia
    Commented Dec 9, 2020 at 10:14
1

You are lacking the inclusion of ragged2e in your preamble:

enter image description here

\documentclass{article}

% tables
\usepackage{booktabs,ragged2e}
\usepackage{tabularx} 
\newcolumntype{C}{>{\Centering}X}
\newcolumntype{P}[1]{>{\RaggedRight}m{#1}}

\begin{document}

\begin{table}[ht]
  \scriptsize
  \newlength\colwidth
  \settowidth\colwidth{30\% acrylamide stock solution30\%} % set width of 1st col.
  \begin{tabularx}{\textwidth}{@{} P{\colwidth} *{2}{C} @{}}
    \toprule
      & Transient transfection & Stable transfection \\
    \midrule
    Advantages
      & no genomic integration (no frameshift, or even worse damage to the genome) high flexibility & \\
    \addlinespace
    cultured cells
      & electroporation / lipofection / microinjection \\
    \bottomrule
  \end{tabularx}
\end{table}

\end{document}
1
  • but how can I do a line break or an enumeration in my table?
    – Elia
    Commented Dec 8, 2020 at 22:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .