Text FormattingChange of Font Size in multi-page Table

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
AstridH
Posts: 6
Joined: Mon Dec 02, 2013 2:03 pm

Change of Font Size in multi-page Table

Post by AstridH »

Hello,

I have a table, which stretches over a few pages and I'm currently using the ltablex package for it (as I would like to use the tabularx environment). The table itself is working OK, but I would like to change the font size for the table only to \footnotesize and I'm not entirely sure how I can do this or better where to place the command within the table. This is the current layout of my table.

Code: Select all

\documentclass[12pt,a4paper]{report}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{ltablex}
\usepackage{booktabs}

\begin{document}

\begin{tabularx}{\textwidth}{p{6cm}p{6cm}}
\caption{some sort of caption} \\
    \toprule
    \textbf{number one} & \textbf{number two} \\
    \toprule
\endfirsthead
    \caption{some sort of caption. (continued)} \\
    \toprule
    \textbf{number one} & \textbf{number two} \\
    \toprule
\endhead
     \bottomrule
     \multicolumn{2}{l}{{Continued on Next Page\ldots}} \\
     \bottomrule
\endfoot
    \bottomrule
\endlastfoot
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\\midrule
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\ \midrule
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\ \midrule
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\ 
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\ 
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\ 
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\ \midrule
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\ 
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\ 
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\
this is going to be & a very long table \\ 
\end{tabularx}

\end{document}
Your help and ideas would be very much appreciated.


Cheers,
Astrid
Last edited by localghost on Tue Dec 17, 2013 11:17 pm, edited 1 time in total.

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

tom
Posts: 73
Joined: Thu Apr 18, 2013 4:02 am

Change of Font Size in multi-page Table

Post by tom »

Hi Astrid,

Nice minimum working example. I'd just enclose the entire {tabularx} with the font size changing environment {footnotesize}. I tried and it seems to work.

Code: Select all

\begin{footnotesize}
\begin{tabularx}{\textwidth}{p{6cm}p{6cm}}
...
\end{tabularx}
\end{footnotesize}
Cheers, Tom
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Change of Font Size in multi-page Table

Post by cgnieder »

Please do not recommend using fontsize switching commands as environments. They can lead to (at least to some users) unexpected results and really should be avoided:

Code: Select all

\documentclass{article}
\usepackage[nopar]{lipsum}% dummy text
\begin{document}
\lipsum[1]

\begin{footnotesize}
  \lipsum[2]
\end{footnotesize}

\lipsum[3]

\begin{footnotesize}
  \lipsum[4]\par
\end{footnotesize}

\lipsum[5]

\end{document}
I'd rather use something like

Code: Select all

\begin{center}
  \footnotesize
  \begin{tabularx}{\textwidth}{p{6cm}p{6cm}}
    
  \end{tabularx}
\end{center}
@Astrid Why are you using a table when you're not using X type columns? It seems rather unnecessary then.

Regards
site moderator & package author
AstridH
Posts: 6
Joined: Mon Dec 02, 2013 2:03 pm

Re: Change of Font Size in multi-page Table

Post by AstridH »

Hi Tom and Clemens,

thanks a lot for your help! I now added the \footnotesize command as suggested by Clemens in his last example and this works just fine. Problem solved :)! I also changed the columns to X type columns - much better! I don't really know why I tried to set the width myself there...it must have been one of those long working evenings. Thanks for pointing this out!!!

Cheers,
Astrod
User avatar
tom
Posts: 73
Joined: Thu Apr 18, 2013 4:02 am

Change of Font Size in multi-page Table

Post by tom »

Thanks for pointing out that using the environment approach to change the font size might lead to unexpected results. Just as a side note, it's generally better to use \par in order to avoid problems.

Code: Select all

\documentclass{article}
\usepackage[nopar]{lipsum}% dummy text
\begin{document}
\lipsum[1]

{\footnotesize\lipsum[2]}

\lipsum[3]

{\footnotesize\lipsum[4]\par}

\lipsum[5]

\end{document}
Post Reply