0

I'm trying to make a good looking table but I'm facing some troubles as shown in the pic for example between the braces are not aligned

enter image description here

I did it in the following way:

\begin{table}[!htb]
   \begin{center}
   \caption{Example}
   \label{tab:table1}
   \hline
   \begin{tabular}{|p{3cm}|p{3cm}|p{3cm}|p{3cm}|p{3cm}|} 
   \textbf{Example} & \textbf{Example} & \textbf{Example} & \textbf{Example (Example/ Example and 
     Example)} & \textbf{Example (Example/Example)} \\
   \hline
     1 & 1110.1 & a & b&c\\
     2 & 10.1 & a & b&c\\
     3 & 23.113231 &a & b&c\
   \end{tabular}
   \end{center}
\end{table}

how can I avoided these problems?

3
  • 3
    Welcome to TeX.SX! Which problems exactly? You might want to move the first \hline into the tabular environment, i.e. \begin{tabular}{...}\hline instead of \hline\begin{tabular}{...}. You table is probably too wide for the width of the text, and the hline outside of tabular ends at the right margin.
    – gernot
    Jan 28, 2021 at 14:57
  • thanks I will try it
    – Karam
    Jan 28, 2021 at 14:58
  • Also extend your code snipped to complete small document beginning with \documentclass and ending with `\end{document}.. BTW, do you really need that long column headers? Try to find some abbreviation and add their explanations in caption or some legend to table.
    – Zarko
    Jan 28, 2021 at 15:17

1 Answer 1

2

One of the possible ways to prettify your table is use threeparttable and abbrevation offot last two column headers:

\documentclass{article}
\usepackage{geometry}
\usepackage{tabularx, threeparttable}
\renewcommand{\tnote}[1]{\textsuperscript{\textbf{[#1]}}}

\begin{document}
    \begin{table}[!htb]
    \centering
    \begin{threeparttable}
\caption{Example}
\label{tab:table1}
    \begin{tabularx}{\linewidth}{ |*{5}{X|} }
    \hline
\textbf{Example} 
    & \textbf{Example} 
        & \textbf{Example} 
            & \textbf{Example A}\tnote{a} 
                & \textbf{Example B}\tnote{b} \\
   \hline
     1 & 1110.1 & a & b&c\\
     2 & 10.1 & a & b&c\\
     3 & 23.113231 &a & b&c\\
     \hline
   \end{tabularx}
\begin{tablenotes}[flushleft]\footnotesize
\item[a]    Example A: Example (Example/ Example and Example),
\item[b]    Example B: Example (Example/Example)
\end{tablenotes}
    \end{threeparttable}
    \end{table}
\end{document}

enter image description here

1
  • thanks a lot for your help I appreciate it
    – Karam
    Jan 28, 2021 at 19:16

You must log in to answer this question.

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