0

For some reason, as I am trying to increase and add columns, it goes offscreen. Why does this happen exactly: Latex:

\documentclass[a4paper,svgnames,11pt]{article}

\textheight = 220mm \textwidth = 150mm \topmargin = 10mm \oddsidemargin = 5.0mm \evensidemargin = 5.0mm \unitlength = 1mm

\usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{amsmath} \usepackage{array} \usepackage{booktabs} \usepackage{fullpage} \usepackage{graphicx} \usepackage{threeparttable} \usepackage{tikz} \usepackage{tabularray}

\usepackage{bbding} \usepackage{pifont} \usepackage{wasysym} \usepackage{amssymb}

\begin{document}

{\renewcommand{\arraystretch}{1.6}% \small \begin{table}[htbp] \centering \caption{Comparison}\label{tab:comparison} \begin{tabular}{ |p{5cm}|p{3cm}|p{3cm}|p{3cm}|p{3cm}|p{3cm}| } \hline OS & \hfil Secure & \hfil Fast & \hfil Beautiful & \hfil Smart & \hfil Error free \ \hline Windows & \hfil \checkmark & \hfil \checkmark & \hfil \checkmark & \ \hline MAC OSX & \hfil \checkmark & \hfil \checkmark & \hfil \checkmark & \ \hline Linux & \hfil \checkmark & \hfil \checkmark & \hfil \checkmark & \ \hline \end{tabular} \end{table}}

\end{document}

Result: enter image description here

Albin M
  • 171
  • width of your table is 20cm, declared text width is 15 cm , so it cannot fit in text area. You may consider to change column types to l or c and by this force that column widths will be adopt to width of cells contents. – Zarko Jan 19 '22 at 23:43
  • @Zarko, How would I do this? – Albin M Jan 19 '22 at 23:44
  • @Zarko, doesn't work. I am sorry. – Albin M Jan 19 '22 at 23:51
  • why are you forcing the columns to be so wide? p{5cm} for the first column seems excessive for the text you show, just use l so the column is the width of its content – David Carlisle Jan 19 '22 at 23:59
  • It works, for sure! See my answer. However, your question is not very clear about desired table layout. – Zarko Jan 20 '22 at 00:01

1 Answers1

1

You have more issues with your MWE (Minimal working example):

  • document layout is not consistent. I suggest to use geometry package for defining it
  • because you load tabularray package I would use it for write your table:
  • MWE with only to your problem related packages is:
\documentclass[a4paper,svgnames,11pt]{article}
\usepackage[hmargin=5mm, vmargin={10mm,67mm}]{geometry} % new

\usepackage{amssymb} \usepackage{tabularray}

\begin{document} \begin{table}[htbp] \centering \caption{Comparison}\label{tab:comparison} \begin{tblr}{hlines, vlines, colspec={l *{5}{c}}, } OS & Secure & Fast & Beautiful & Smart & Error free \ Windows & \checkmark & \checkmark & \checkmark & & \ MAC OSX & \checkmark & \checkmark & \checkmark & & \
Linux & \checkmark & \checkmark & \checkmark & & \ \end{tblr} \end{table} \end{document}

enter image description here

(gray lines are borders of page)

Also seven columns can be fit in text area:

\documentclass[a4paper,svgnames,11pt]{article}
\usepackage[hmargin=5mm, vmargin={10mm,67mm}]{geometry} % new

\usepackage{amssymb} \usepackage{tabularray}

\begin{document} \begin{table}[htbp] \centering \caption{Comparison}\label{tab:comparison} \begin{tblr}{hlines, vlines, colspec={l *{7}{X[c,m]}}, } OS & Secure & Fast & Beautiful & Smart & Error free & & \ Windows & \checkmark & \checkmark & \checkmark & & & & \ MAC OSX & \checkmark & \checkmark & \checkmark & & & & \
Linux & \checkmark & \checkmark & \checkmark & & & & \ \end{tblr} \end{table} \end{document}

enter image description here

Zarko
  • 296,517