I'm starting my learning in LaTeX at university and I need to insert the tables below in my text, but they escape the margins. Is there an automatic command in LaTeX that adjusts the size of columns and font so that the table fits within the text margins?
I don't know much about the codes, practically everything you are seeing I took from other sites. Thanks in advance.
\begin{table}[!ht]
\centering
\caption{Representação}
\begin{tabular}{c | c c c c c c c c c c c c c}
\textbf{} & \textbf{brócolis} & \textbf{com} & \textbf{comidas} & \textbf{ela} & \textbf{ele} & \textbf{fez} & \textbf{gosta} & \textbf{milho} & \textbf{palmito} & \textbf{pizza} & \textbf{salada} & \textbf{são} & \textbf{vapor} \\
\hline
$d_1$ & 1 & 0 & 0 & 1 & 1 & 0 & 1 & 1 & 0 & 1 & 0 & 0 & 0 \\
$d_2$ & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 1 & 0 & 1 & 0 \\
$d_3$ & 1 & 1 & 0 & 0 & 1 & 1 & 0 & 1 & 1 & 0 & 1 & 0 & 0 \\
$d_4$ & 1 & 1 & 0 & 1 & 0 & 0 & 1 & 1 & 0 & 0 & 0 & 0 & 1 \\
\end{tabular}
\label{tab:boolean}
\end{table}
\begin{table}[!ht]
\centering
\caption{Representação}
\begin{tabular}{c | c c c c c c c c c c c c c}
\textbf{} & \textbf{brócolis} & \textbf{com} & \textbf{comidas} & \textbf{ela} & \textbf{ele} & \textbf{fez} & \textbf{gosta} & \textbf{milho} & \textbf{palmito} & \textbf{pizza} & \textbf{salada} & \textbf{são} & \textbf{vapor} \
\hline
$d_1$ & 0,000 & 0,000 & 0,000 & 0,301 & 0,301 & 0,000 & 0,602 & 0,000 & 0,000 & 0,602 & 0,000 & 0,000 & 0,000 \
$d_2$ & 0,000 & 0,000 & 0,602 & 0,000 & 0,000 & 0,000 & 0,000 & 0,000 & 0,000 & 0,301 & 0,000 & 0,602 & 0,000 \
$d_3$ & 0,000 & 0,301 & 0,000 & 0,000 & 0,301 & 1,204 & 0,000 & 0,000 & 0,602 & 0,000 & 1,806 & 0,000 & 0,000 \
$d_4$ & 0,000 & 0,301 & 0,000 & 0,301 & 0,000 & 0,000 & 0,301 & 0,000 & 0,000 & 0,000 & 0,000 & 0,000 & 0,602 \
\end{tabular}
\label{tab:tfidf}
\end{table}

[!ht]it might be useful to over-ride the defaults in special situations, but it disables much of latex's float placement algorithm. – David Carlisle Sep 03 '22 at 07:47