1

I'm writing a table on latex, this is the code that I used.

\begin{table}[]
\centering
\begin{tabular}{|l|l|}
\hline
Lalalal                                        & Papapa        \\ \hline
$\p{6^2,m} \hspace{0.3cm} \T{for,} m=2,3,4,6$. & $\p{0;4,4,6}$ \\ \hline
$x^2= graham$                                  & $1+1$         \\ \hline
\end{tabular}
\end{table}

And this is how it looksenter image description here

My problem is simple: The super indices like $6^2$ intersects the horizontal lines of the table and I don't like it. Anyone has some solution? Maybe amplifying the vertical size or something like that. Thanks

3
  • The macros of package booktabs can style-up your table and make it more pretty. :-)
    – Johannes_B
    Jul 22, 2016 at 5:59
  • Do you know exactly what macro do I need?
    – Miguel
    Jul 22, 2016 at 6:04
  • What are the \T and \p commands supposed to do?
    – Bernard
    Jul 22, 2016 at 9:31

2 Answers 2

1

I would like to answer you question using the following MWE:

\documentclass{article}

\usepackage{array}
\usepackage{amstext}

\begin{document}
\def\p#1{(#1)}
\def\T#1{\text{#1}}

\begin{table}[t]
\centering
\extrarowheight=3pt
\begin{tabular}{|l|l|}
\hline
Lalalal                                        & Papapa        \\[3pt] \hline
$\p{6^2,m} \hspace{0.3cm} \T{for, } m=2,3,4,6$. & $\p{0;4,4,6}$ \\[3pt] \hline
$x^2= graham$                                  & $1+1$         \\[3pt] \hline
\end{tabular}
\end{table}

\begin{table}[t]
\centering
\begin{tabular}{|l|l|}
\hline
Lalalal                                        & Papapa        \\ \hline
$\p{6^2,m} \hspace{0.3cm} \T{for, } m=2,3,4,6$. & $\p{0;4,4,6}$ \\ \hline
$x^2= graham$                                  & $1+1$         \\ \hline
\end{tabular}
\end{table}
\end{document}

In the first table, I have added \extrarowheight to add vertical space above the content and used \\[3pt] at end of every row to add vertical space below the row. See the difference in both tables below.

enter image description here

1

With package makecell and its macros \setcellgapes{...} and \makegapedcells you can obtain:

\documentclass{article}
\usepackage{makecell}
\renewcommand\theadfont{\normalsize}

\begin{document}
    \begin{table}[h]
\centering
\makegapedcells
\setcellgapes{5pt}
\makegapedcells
\begin{tabular}{|l|l|}
\hline
\thead[l]{Lalalal}          &   \thead[l]{Papapa}\\ 
    \hline
$\left(6^2,m\right)$  for $m=2,3,4,6$.   
                            &   $(0;4,4,6)$     \\
    \hline
$x^2  = \mathit{graham}$    &   $1+1$           \\
    \hline
\end{tabular}
    \end{table}
\end{document}

You must log in to answer this question.

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