How can I make my table automatically resize? It is too wide and getting cut off the right of the page [duplicate]

    **preamble**
\documentclass[12pt]{amsart}
\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{graphicx}
\graphicspath{ {./documents/} }
\usepackage{array}
\usepackage{tabularx}

\geometry{a4paper}
\begin{document}
**table**
\begin{table}[]
\begin{tabular}{@{}ll@{}}
\toprule
Organisation                      & Role                                                                                                                                                                                                                                                                                                                                          \\ \midrule
Courts                            & \begin{tabular}[c]{@{}l@{}}Judges and lawyers were Nazi members and enforced an improvised "Nazi law"\\ \\ Special courts set up to prosecute political crimes\end{tabular}                                                                                                                                                                   \\
Gestapo                           & \begin{tabular}[c]{@{}l@{}}Secret state police set up by Göring in 1933. Himmler gained control after 1933, and by 1936, an established part of the SS\\ \\ Enforce political conformity, but relied on denunciations by the German population. In Würzburg, 54\% of race-related charges were initiated by private citizens.\end{tabular}    \\
SS (Schutzstaffel - Defense Unit) & \begin{tabular}[c]{@{}l@{}}Private army and security system set up by Hitler's personal guards in 1925, led by Himmler after 1929. \\ \\ Key role in Kristallnacht -\textgreater replaced the SA as main military unit\\ \\ Enforce racial policy and run concentration camps\\ \\ Sub units: 1) Death's Head Units 2) Waffen SS\end{tabular} \\
SD (Sicherheitsdienst)            & \begin{tabular}[c]{@{}l@{}}Set up in 1932 by Himmler\\ \\ Internal security force of SS. Main role was intelligence eg. reports of SD, popularity of party, situation of Church\end{tabular}                                                                                                                                                  \\
Concentration Camps               & \begin{tabular}[c]{@{}l@{}}First used to detain political opponents (communists and socialists), later anybody who spoke out against the regime\\ \\ Forced labour from prisoners. Camps were then built near stone quarries and brick making factories\end{tabular}                                                                          \\ \bottomrule
\end{tabular}
\end{table}
\end{document}


When I compile, it cuts off the page. I've tried looking at other stack exchange solutions but they didn't work for me (or at least my solo troubleshooting). Will tabularx automatically create new sentences when they are long?

• Your code cannot be compiled. – Dr. Manuel Kuehner Mar 25 at 0:59
• – Dr. Manuel Kuehner Mar 25 at 1:00
• sorry yes that was the version that didn't worked when I tried a self fix with tabularx. Should work now – user71207 Mar 25 at 1:01
• – Dr. Manuel Kuehner Mar 25 at 1:01
• Please test your code before you post it. It is still not comparable (\begin{document} missing for example). – Dr. Manuel Kuehner Mar 25 at 1:02

• Based on https://blog.modelworks.ch/automatic-line-breaks-in-latex-tables/.
• Your code is a mess :), e. g. you load tabularx two times and you load geometry two times. In addition, the **preamble** at the beginning caused an additional compilation error for me which I first had to find.
• Not sure why you use \begin{tabular} inside \begin{tabular}.
• You also did not use tabularx in your code.

\documentclass{article}
\usepackage{booktabs}
\usepackage{tabularx}
\begin{document}

\begin{table}
\centering % not needed
\begin{tabularx}{\textwidth}{lX}
\toprule
Organisation     & Role \\
\midrule
Courts & Judges and lawyers were Nazi members and enforced an improvised "Nazi law" Special courts set up to prosecute political crimes \\
\bottomrule
\end{tabularx}%