I have a table that, due to long text, is not fitting on the (landscape) page. consider this code as an example (packages used in the actual document, so included them to avoid compatibility issues):
\documentclass[a4paper,12pt]{article}
\usepackage{natbib}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{lmodern}
\usepackage{csquotes}
\usepackage[ddmmyyyy]{datetime}
\usepackage{color}
\usepackage{enumerate}
\usepackage{enumitem}
\usepackage{float}
\usepackage{lscape}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{mathtools}
\begin{document}
\begin{landscape}
\begin{table}[]
\begin{tabular}{@{}|c|c|c|c|c|c|c|c|c|@{}}
\toprule
\textbf{header 1} & \multicolumn{2}{c|}{header 2} & \multicolumn{4}{c|}{header 3} & \multicolumn{2}{c|}{header 4}\\ \midrule
\textbf{tex1} & foo & text here & some more, longer text &really long text here that makes table wide&text&longer text&more text& text that is also really long \\ \bottomrule
\end{tabular}
\caption{individuals reactions by actor-specific characteristics}
\label{tab:individuals reactions by actor-specific characteristics}
\end{table}
\end{landscape}
\end{document}
I cannot get other solutions like this one to work that are using p{width}
or resizebox
which are mentioned elsewhere due to the \begin{tabular}{@{}|c|c|c|c|c|c|c|c|c|@{}}
-line in my code.
As I'm rather new to LaTeX, could someone point me to the best solution? Thanks a lot and all the best.
c
,l
andr
columns cannot break the cells texts, so the column width is fixed by the cell with the longest text. But you can change that columns types by ap
column of fixed witdth that allow text wrapping. E.g.: Instead of some like\begin{tabular}{c|r|l}
you ca use some like\begin{tabular}{p{3cm}|p{6em}|p{0.25\linewidth}}}