3

How do I change the font size in my table?

I have tried the \normalsize and \small commands, but it doesnt make any difference. I needed to specify column length to get the design I wanted, does this have something to do with it?

Here is a part of my code:

\documentclass[a4paper,11pt,twoside]{report}
\begin{document}
    \begin{table}[h] 
    \caption[text} 
    \label{Tsomething} 
    \centering

    \renewcommand\arraystretch{2} 
    \resizebox{\textwidth}{!}
    {% \begin{tabular}{@{}|c|p{15cm}|p{15cm}|c|@{}} 
    \toprule 
    \textbf{Resource} & \textbf{Type} & \textbf{Application} & \textbf{Comment} \\
    \midrule 
    bla. & bla & bla &  \\ 
    \midrule 
    bla. & bla & bla & \\ 
    \midrule 
    bla. & bla & bla & \\ 
    \midrule 
    bla. & bla & bla & \\ 
    \midrule 
    bla. & bla & bla &  \\ 
    \midrule 
    bla. & bla & bla & \\ 
    \midrule bla. & bla & bla & \\ 
    \midrule bla. & bla & bla & \\ 
    \bottomrule \end{tabular}% } 
    \end{table}
 \end{document}  

I have some long sentences in the table, and i want latex to put these in several lines, instead of minimizing the font size to put it all in the same line. This is why i dont use the following code (then i can barely see the text).

\documentclass[a4paper,11pt,twoside]{report}
\begin{document}
    \begin{table}[h] 
    \caption[text} 
    \label{Tsomething} 
    \centering

    \renewcommand\arraystretch{2} 
    \resizebox{\textwidth}{!}
    {% \begin{tabular}{@{}|c|c|c|c|@{}} 
    \toprule 
    \textbf{Resource} & \textbf{Type} & \textbf{Application} & \textbf{Comment} \\
    \midrule 
    bla. & bla & bla &  \\ 
    \midrule 
    bla. & bla & bla & \\ 
    \midrule 
    bla. & bla & bla & \\ 
    \midrule 
    bla. & bla & bla & \\ 
    \midrule 
    bla. & bla & bla &  \\ 
    \midrule 
    bla. & bla & bla & \\ 
    \midrule bla. & bla & bla & \\ 
    \midrule bla. & bla & bla & \\ 
    \bottomrule \end{tabular}% } 
    \end{table}
 \end{document}   

Thank you for any help.

  • 2
    Could you please add a fully compilable MWE? – Raaja Apr 23 at 15:07
  • 2
    Well, what do you expect at a table more than 30 cm wide (longer than the length of an A4 sheet)? Why is it necessary to have 15cm in those columns? – user156344 Apr 23 at 15:24
  • (i) your code snippet contain errors, (ii) provide more realistic content of table; from presented follows, that you not need p{...} columns type (iii) vertical lines and rules from booktabs should not be used together, (why you need so big stretch of table , ... etc. please provide complete small document (mwe: minimal working example) beginning with \documentclass and ending with \end{document}.with example of one or two real rows (simulated by dummy, but equal long text). – Zarko Apr 23 at 15:37
  • Raaja: Sorry, i hope the code is compilable now. JouleV: You are right, i dont want a table of 30 cm. I want latex to put line breaks in automatically so the text is not supersmall and unreadable. Zarko: can you please elaborate which errors you refer to? I am unfamiliar with using dummy variables, but i will try to make one. Thank for your help. – SGS Apr 23 at 17:45
1

you might looking for the following result:

enter image description here

table width is equal to text width, font size is \small, widths of the second and third columns are equal and determined automatically by package `tabular

\documentclass[a4paper,11pt,twoside]{report}
\usepackage{ragged2e}
\usepackage{booktabs, tabularx}
\newcolumntype{L}{>{\RaggedRight}X}
\usepackage[skip=1ex]{caption}

\usepackage{lipsum}% for dummy text

\begin{document}
    \begin{table}[htb]
\caption{text}
\label{Tsomething}
    \centering
    \small
    \renewcommand\arraystretch{1.2}
\begin{tabularx}{\linewidth}{@{}c L L c@{}}
    \toprule
\textbf{Resource}
    & \textbf{Type}
        & \textbf{Application}
            & \textbf{Comment}  \\ 
    \midrule
bla.    & \lipsum[1][1-3] & \lipsum[1][1-3] &       \\ 
bla.    & bla           & bla   &       \\ 
bla.    & bla           & bla   &       \\ 
bla.    & bla           & bla   &       \\ 
bla.    & bla           & bla   &       \\ 
bla.    & bla           & bla   &       \\ 
bla.    & bla           & bla   &       \\ 
bla.    & bla           & bla   &       \\
    \bottomrule
\end{tabularx}
    \end{table}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.