Graphics, Figures & Tablesproblem with tables

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Kelkut
Posts: 4
Joined: Fri Nov 20, 2020 6:55 pm

problem with tables

Post by Kelkut »

Hi, i'm having some problems with a table. It is a simple 2 columns table but in the 2 column i have a lot of text in every cell and my table has to be confined in my column (IEEE standard).
I used

Code: Select all

\begin{adjustbox}{max width = \columnwidth}
to fix the table in the column dimensions,

Code: Select all

\begin{tabular}{|p{4em}|p{33.5em}|}
to set the dimension of my cells. Here i have my first problem, i want to center the codes (P1, P2, etc) in the fist column's cells both vertically and horizzontally but if i use "c" instead of p, my table gets smaller.

My second problem is that the lines created with

Code: Select all

\hline
are too close to my text. I need some space above and below (even a single millimeter).

Can you help me?

Thanks

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

problem with tables

Post by Ijon Tichy »

Your questions are quite unclear. It would be good to always ask exactly one question per posting and add a dedicated Infominimal working example. Without, I can only gamble: Use package array to add >{\centering} or (better) ragged2e's >{\Centering} to your column declaration and use m columns instead of p columns. Use package booktabs for horizontal lines with extra space above and below. But this would collide with vertical lines. Generally, as the booktabs manual explains: vertical lines should be avoided.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Kelkut
Posts: 4
Joined: Fri Nov 20, 2020 6:55 pm

problem with tables

Post by Kelkut »

Sorry for not being clear. Here is the code (the text is obviously not the original one but the concept is the same).

Code: Select all

\begin{table}[tbp]
  \centering
  \caption{caption test)}
\begin{adjustbox}{max width = \columnwidth}
    \begin{tabular}{|p{4em}|p{33.5em}|}
    \hline
    \normalsize \textbf{ASD1} & \normalsize aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \\
    \hline
    \normalsize \textbf{ASD2} & \normalsize aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaa\\
    \hline
    \normalsize \textbf{ASD3} & \normalsize aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaa \\
    \hline
    \normalsize \textbf{ASD4} & \normalsize aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
    \hline
    \normalsize \textbf{ASD5} & \normalsize aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
    \hline
    \normalsize \textbf{ASD6} & \normalsize aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \\
    \hline
    \normalsize \textbf{ASD7} & \normalsize aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaa \\
    \hline
    \normalsize \textbf{ASD8} & \normalsize aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \\
    \hline
    \normalsize \textbf{ASD9} & \normalsize aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaa \\
    \hline
    \normalsize \textbf{ASD10} & \normalsize aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
    \hline
    \normalsize \textbf{ASD11} & \normalsize aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaa\\
    \hline
    \end{tabular}
    \end{adjustbox}
  \label{tab:mandatory}
\end{table}
This is the result:
table.png
table.png (6.62 KiB) Viewed 2079 times
I need the "ASD#" to be vertically centered too and more space between the lettering and lines. I had already used booktabs noting the problem with vertical lines. Are there other ways?

Thanks

EDIT:

I solved the centering problem this way:

Code: Select all

\begin{tabular}{|>{\centering\arraybackslash}c|m{33.5em}|}
Now i only need to have more space between lettering and lines
Kelkut
Posts: 4
Joined: Fri Nov 20, 2020 6:55 pm

problem with tables

Post by Kelkut »

I solved using tabularx and adding this line of code :

Code: Select all

\renewcommand\tabularxcolumn[1]{m{#1}}% for vertical centering text in X column
Thanks for your help.
Post Reply