2

I'm new to LaTex and it seems like there's a high learning curve. I have the following table:

\begin{table}[ht]
  \centering\settowidth\rotheadsize{Next concept/}
  \renewcommand\cellalign{cl}
  \renewcommand\arraystretch{1.25}
  \caption{Title}
  \begin{tabular}{|l|c|c|c|c}
    \toprule\noalign{\vskip-1pt}\hline
    \diagbox[height=1.25\rotheadsize]{\raisebox{3ex}{Layers}}{\raisebox{-4ex}{Neurons}} & 10 & 20 & 64 \\
    \hline
    2 & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) \\
    4 & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) \\
    8 & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) \\
    12 & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) \\
    \hline\bottomrule
  \end{tabular}
\end{table}

enter image description here

It's a bit hard to see, but it continues too much to the right which is my main concern. Is there an easy fix for this? I tried playing with the height and arraystretch, but it didn't seem to work.

Penguin
  • 295
  • We need to see your page layout. Please extend your document fragment to complete, compilable document. In preamble should be loaded only to your table relevant packages. – Zarko Jun 29 '21 at 00:56

1 Answers1

5
  • Apparently your table is wider than \textwidth. Consequently it protrude right text border.
  • What you can do:
    • Increase \textwidth by loading geometry package.
    • Redesign table so, that the first column is narrower. This can be done by omitting of \diagbox and introduce new row (see MWE below):
\documentclass{article}
\usepackage{geometry}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%
\usepackage{lipsum}                             % for dummy text
%---------------------------------------------------------------%
\usepackage{booktabs}
\usepackage[skip=1ex]{caption}

\begin{document} \begin{table}[ht] \caption{Title} \label{tab:neurons} \centering \renewcommand\arraystretch{1.1} \begin{tabular}{@{} *{4}{c} @{}} \toprule & \multicolumn{3}{c}{Neurons} \ \cmidrule(l){2-4} Layers & 10 & 20 & 64 \ \midrule 2 & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) \ 4 & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) \ 8 & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) \ 12 & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) \ \bottomrule \end{tabular} \end{table} \end{document}

  • By this change table has more "profesional" looks:

enter image description here

(red lines indicate page layout)

Zarko
  • 296,517