0

I am trying to adjust the table to the \textwidth but it changes the size of the font and becomes too big. Is there any way to fix the width of the table to the margins (1\textwidth) without changing automatically the fontsize? Using \tiny seems not to work. Thank you very much any help is appreciate it

\begin{table}[!htb]

\centering
\begin{adjustbox}{width=1\textwidth}    
    \tiny           
    \begin{tabular}{|c|ccc|}            
        \hline
        \cellcolor{azultabla}{\textbf{\tiny{Range}}}& 
        \multicolumn{3}{c|}{\cellcolor{azultabla}{\textbf{\tiny{Return }}}}                                                                 
        \\ 
        \hline
        & 
        \multicolumn{1}{c|}{\tiny{Spec.}}& 
        \multicolumn{1}{c|}{\tiny{Meas.}}& 
        \tiny{Pass / Fail}        
        \\ 
        \hline
        \tiny{RF}& 
        \multicolumn{1}{c|}{\tiny{\textgreater 10}}& 
        \multicolumn{1}{c|}{\tiny{xxxx}}& 
        \tiny{xxxx}                    
        \\ 
        \hline
        \tiny{IF}& 
        \multicolumn{1}{c|}{\tiny{\textgreater 10.9}}& 
        \multicolumn{1}{c|}{\tiny{xxxx}}& 
        \tiny{xxxx}                    
        \\ 
        \hline
    \end{tabular}
\end{adjustbox}

\end{table}

Carlos
  • 1
  • Not quite understood. Are you trying to create a table that is as wide as the text, but the current one is too small and thus adjustbox scales it up? – daleif Nov 29 '22 at 13:21
  • 6
    never use adjustbox or resizebox on tables it forces inconsistent fonts as you show – David Carlisle Nov 29 '22 at 13:21
  • 2
    It is hard to understand your code as you did not provide a full minimal example so others cannot just copy and test your code. – daleif Nov 29 '22 at 13:21
  • 2
    \tiny does not take an argument use \tiny abc not \tiny{ABC} – David Carlisle Nov 29 '22 at 13:23
  • Thanks for the answers. I want to fix the size of a table to the margins (2cm left and 2cm right). If i use {adjustbox}{width=1\textwidth}, then okay, it is fixed to the margins but the fontsize of the content of the table grows a lot. I want to fix this size without changing the size of the content of my table. – Carlos Nov 29 '22 at 13:26
  • 1
    Perhaps you should have a look at the tabularx package instead – daleif Nov 29 '22 at 13:28
  • Will have a look. I appreciate it – Carlos Nov 29 '22 at 13:30
  • See also tabular* (adjusts spaces between columns). Standard LaTeX. – John Kormylo Nov 29 '22 at 15:23
  • As said, do not resize the table, use tabular*, talbularx or tabulary to fit it to \linewidth (always safer than to \textwidth) and then reduce the font if needed. Also consider a \centering before a simple tabular without insisting on stretching the table to the margins, it could look even better. – Fran Nov 29 '22 at 19:59

1 Answers1

1

Never scale tables it just produces inconsistent font sizes. If you do want small text the syntax is \tiny xxx not \tiny{xxx} it does not take an argument.

You can specify a full width table in various ways, I use tabularx here, although the unstretched table is easier to read. I also removed the \multicolumn{1} as they were not doing anything.

enter image description here

\documentclass{article}
\usepackage[tables]{xcolor}
\usepackage{tabularx,colortbl}
\definecolor{azultabla}{rgb}{1,0,0}
\begin{document}

\begin{table}[!htb]

\centering \begin{tabular}{|c|c|c|c|}
\hline \cellcolor{azultabla}{\textbf{Range}}& \multicolumn{3}{c|}{\cellcolor{azultabla}{\textbf{Return}}}
\ \hline & Spec.& Meas.& Pass / Fail
\ \hline RF& \textgreater 10& xxxx& xxxx
\ \hline IF& \textgreater 10.9& xxxx& xxxx
\ \hline \end{tabular}

\bigskip \newcolumntype{C}{>{\centering\arraybackslash}X} \begin{tabularx}{\textwidth}{@{}|C|C|C|C|@{}}
\hline \cellcolor{azultabla}{\textbf{Range}}& \multicolumn{3}{c|}{\cellcolor{azultabla}{\textbf{Return}}}
\ \hline & Spec.& Meas.& Pass / Fail
\ \hline RF& \textgreater 10& xxxx& xxxx
\ \hline IF& \textgreater 10.9& xxxx& xxxx
\ \hline \end{tabularx}

\end{table}

\end{document}

David Carlisle
  • 757,742