Graphics, Figures & TablesFont Size in the table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
ciema7
Posts: 22
Joined: Sat Nov 10, 2018 2:31 am

Font Size in the table

Post by ciema7 »

Hello Everyone,

I tried to find the solution but options i found didnt work. I need to present my results in table, but font size is too small.
Can You help me increase font size, but not changing my settings for the whole document (and keep table adjusted to the page size)?

Here is my code:



\documentclass[fontsize=12pt]{article}
\usepackage[table,xcdraw]{xcolor}
\usepackage{listings}
\usepackage{inputenc}
\usepackage{graphicx}
\usepackage{polski}
\usepackage{geometry}
\usepackage{textcomp}
\usepackage{gensymb}
\usepackage{parskip}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{enumitem}
\usepackage{booktabs}
\usepackage{array}
\usepackage{caption}
\usepackage{amsmath}
\usepackage{scrextend}
\usepackage{mwe}
\usepackage[export]{adjustbox}
\usepackage{setspace}
\usepackage{stanli}
\usepackage{tikz}
\usepackage{wrapfig}
\usepackage{hyperref}
\usepackage[numbers,sort&compress]{natbib}
\usepackage[,framed]{matlab-prettifier}
\usepackage{pdfpages}
\usepackage{placeins}
\usepackage{bm}
\usepackage{float}
\pagenumbering{arabic}
\usepackage{leading}
\leading{18pt}


\captionsetup[figure]{font=footnotesize,labelfont=footnotesize}



\lstset{language=matlab,basicstyle=\footnotesize,showstringspaces=false,style = Matlab-editor,basicstyle=\mlttfamily,
escapechar= ",mlshowsectionrules = true}


\graphicspath{ {figures/} }



\begin{document}

\begin{table}[H]
\begin{flushleft}
\hspace{-0.1cm}\text{ Tab. 5 \textit{Wyniki analizy statycznej dla wariantu nr 4 obciążenia korpusu}}
\end{flushleft}


\def\arraystretch{2.5}
\renewcommand{\tabcolsep}{3mm}
\resizebox{\textwidth}{!}{
\vspace{-0.2cm}\begin{tabular}{|c|c|c|c|c|c|}
\hline
\rowcolor[RGB]{31,78,121}

{\color[HTML]{FFFFFF} \textbf{Wariant obciążenia korpusu nr 4}} & {\color[HTML]{FFFFFF} \textbf{\begin{tabular}[c]{@{}c@{}}Maksymalne przemieszczenia \\ dla kierunku x {[}mm{]}\end{tabular}}} & {\color[HTML]{FFFFFF}\textbf{\begin{tabular}[c]{@{}c@{}}Maksymalne przemieszczenia \\ dla kierunku y {[}mm{]}\end{tabular}}} & {\color[HTML]{FFFFFF} \textbf{\begin{tabular}[c]{@{}c@{}}Maksymalne przemieszczenia \\ dla kierunku z {[}mm{]}\end{tabular}}} & {\color[HTML]{FFFFFF} \textbf{Maksymalne przemieszczenia wypadkowe {[}mm{]}}} & {\color[HTML]{FFFFFF} \textbf{Maksymalne naprężenia wypadkowe {[}MPa{]}}} \\ \hline

\rowcolor[RGB]{31,78,121}
\cellcolor[RGB]{31,78,121}{\color[HTML]{FFFFFF} \textbf{\begin{tabular}[c]{@{}c@{}}Zastosowanie podpory nieprzesuwnej \\ w 4. otworach montażowych,\\ zgodnie z rys.32\end{tabular}}} & \cellcolor[RGB]{208,206,206}0,0015484 & \cellcolor[RGB]{208,206,206}0,000068087 & \cellcolor[RGB]{208,206,206}0,001327 & {\color[HTML]{000000}\cellcolor[RGB]{208,206,206} 0,0054075}& {\color[HTML]{000000}\cellcolor[RGB]{208,206,206} 4,0204} \\ \hline \rowcolor[RGB]{31,78,121}
\cellcolor[RGB]{31,78,121}{\color[HTML]{FFFFFF} \textbf{\begin{tabular}[c]{@{}c@{}}Zastosowanie podpory nieprzesuwnej \\ w 4. otworach montażowych\\ i podpory beztarciowej na powierzchniach \\ od spodu korpusu,\\ zgodnie z rys. 33\end{tabular}}} & \cellcolor[RGB]{208,206,206}0,00074249 & \cellcolor[RGB]{208,206,206}0,000042951 & \cellcolor[RGB]{208,206,206}0,00031933 & {\color[HTML]{000000} \cellcolor[RGB]{208,206,206}}0,0040384 & {\color[HTML]{000000} \cellcolor[RGB]{208,206,206}1,0427} \\ \hline

\rowcolor[RGB]{31,78,121}
\cellcolor[RGB]{31,78,121}{\color[HTML]{FFFFFF}\textbf{Błąd względny {[}\%{]}}} &
\cellcolor[RGB]{208,206,206}52 &
\cellcolor[RGB]{208,206,206}36,9 &
\cellcolor[RGB]{208,206,206}75,9 &
\cellcolor[RGB]{208,206,206}25,3 &
\cellcolor[RGB]{208,206,206}74 \\ \hline
\end{tabular}
}

\end{table}

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Font Size in the table

Post by Ijon Tichy »

If you shrink a house to a matchbox, you should not expect to be able to enter the door.

So you have to redesign your table to not longer need the \resizebox{\textwidth}{!}{…}. Otherwise changing the font size wouldn't change a lot, because the font always would be resized to a very tiny one by the \resizebox command.

BTW: You should not set the table caption manually but use \caption. You are already loading package caption, so you can use this package to configure the design of the captions. Using \caption would also allow you to use \label and \ref to reference your tables.

Package parskip should be loaded after scrextend or you should replace fontsize=12pt by 12pt. Otherwise parskip would set the paragraph skip relative to 10pt instead of 12pt.

Most packages are not needed for the Infominimal working example. Some are even more or less useless (e.g. loading setspace before loading and using leading). So it would be useful, if you would reduce your document preamble. And you should use the "Code" button or "Select code" selecting "TeX (LaTeX)" to add your source code.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
ciema7
Posts: 22
Joined: Sat Nov 10, 2018 2:31 am

Font Size in the table

Post by ciema7 »

Many thanks for help!
Post Reply