# Alternative of \resizebox{\textwidth}{!} for homogenously fixing font size for multiple lines

I am trying to list three different sentences:

 \begin{tabular}{@{}p{0.4in}p{0.3in}p{4in}}
Fall &2015 &Teaching Assistant, Machine Learning (Andrew Ng)\\
Winter &2016 &Teaching Assistant, Cryptography (Dan Boneh)\\
Winter &2017&Teaching Assistant,
Probabilistic Graphical Model (Stefano Ermon)\\
\end{tabular}


But this gives

So I changed it and used \resizebox{\textwidth}{!} from graphicx package.

    \begin{tabular}{@{}p{0.4in}p{0.3in}p{4in}}
Fall &2015 &Teaching Assistant, Machine Learning (Andrew Ng)\\
Winter &2016 &Teaching Assistant, Cryptography (Dan Boneh)\\
Winter &2017&\resizebox{\textwidth}{!}{Teaching Assistant,
Probabilistic Graphical Model (Stefano Ermon)}\\
\end{tabular}


But this makes text of third line much larger compared to above two.

What's the best practice to control font size in this kind of situation so that all the lines have same font size at the same time fit on one line?

• Welcome to TeX.SE!. Try by starting \resizebox{\textwidth}{!}{ before the environment. The right brace } has to be placed at the end, right after \end{tabular} – Cragfelt Oct 30 '17 at 8:35
• Please don't use resizebox for tables. This will just scale the font without choosing a font of appropriate size. If you insist on changing the font size of the table, do it manually, e.g. \fontsize{10pt}{12pt}\selectfont. – user36296 Oct 30 '17 at 11:41
• the font is larger because \textwidth is larger than the width allowed for the column, but the string you are placing in it is not quite that wide. you may end up with a line that is wider than the width of the text block. better to adjust the width of the column, as suggested in the answers, or even to set the column \raggedright, avoiding hyphenation.. – barbara beeton Oct 31 '17 at 0:50

Using another scaling of the font (which you get using \resizebox) or another fontsize for only a small portion of a document will look really strange. My suggestion instead is split the last cell in two lines and let latex determine the optimal columns widths:

\documentclass{article}

\usepackage{tabularx}

\begin{document}

\begin{tabularx}{\linewidth}{@{}llX@{}}
Fall &2015 &Teaching Assistant, Machine Learning (Andrew Ng)\\
Winter &2016 &Teaching Assistant, Cryptography (Dan Boneh)\\
Winter &2017&Teaching Assistant,
Probabilistic Graphical Model\newline (Stefano Ermon)\\
\end{tabularx}

\end{document}


If you insist on a single line, you could save a btit of space beteween the columns and make the last one a bit wider (as I don't know which documentclass etc. you are using I cannot say if this will fit in your textwidth or not)

\setlength{\tabcolsep}{3pt}
\begin{tabular}{@{}llp{4.03in}@{}}
Fall &2015 &Teaching Assistant, Machine Learning (Andrew Ng)\\
Winter &2016 &Teaching Assistant, Cryptography (Dan Boneh)\\
Winter &2017&Teaching Assistant,
Probabilistic Graphical Model (Stefano Ermon)\\
\end{tabular}