Document ClassesControlling font size in math mode

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
noematic.logos
Posts: 19
Joined: Thu May 15, 2008 8:31 pm

Controlling font size in math mode

Post by noematic.logos »

Hello everyone,

I'm sure this is simple but I can't find a solution for this. I have a table defined with a custom column to align along the decimal point. As a result, the content is being treated as being in math mode. Because the table is large, I'd like to reduce the size of the font in each cell, but normal font size commands do not work in math mode. I tried using the relsize command in the column definition but that doesn't seem to work. So is it possible to control the font size in math mode? Thanks in advance!

Code: Select all

>{\relsize{-1}}d{1}{2}  % didn't work
>{\small} d{1}{2}       % didn't work

... & \small 0.1 & ... \NN   % didn't work

Code: Select all

\usepackage{dcolumn}
\usepackage{ctable}

\newcolumntype{d}[2]{D{.}{.}{#1.#2}}

\ctable[
	caption=Title,
	pos=h
	]{ld{1}{2}@{}d{1}{2}d{1}{2}@{}d{1}{2}d{1}{2}@{}d{1}{2}d{1}{2}@{}d{1}{2}d{1}{2}@{}d{1}{2}d{1}{2}@{}d{1}{2}}{%
}
{\FL
\multicolumn{1}{l}{Component} & \multicolumn{2}{c}{2} & \multicolumn{2}{c}{3} & \multicolumn{2}{c}{4} & \multicolumn{2}{c}{5} & \multicolumn{2}{c}{6} & \multicolumn{2}{c}{7} \ML
1. Component & 0.1 & 0.1 & 0.1 & 0.1 & 0.1 & 0.1 & 0.1 & 0.1 & 0.1 & 0.1 & 0.1 & 0.1          \NN
2. Component & & & & & & & & & & & &       \NN
3. Component & & & & & & & & & & & &        \NN
4. Component & & & & & & & & & & & &       \NN
5. Component & & & & & & & & & & & &        \NN
6. Component & & & & & & & & & & & &         \NN
7. Component & & & & & & & & & & & &          \LL 
}

Recommended reading 2024:

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

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

balf
Posts: 158
Joined: Sat Jan 12, 2008 1:11 am

Re: Controlling font size in math mode

Post by balf »

Two solutiions might work: 1) relsize has a \mathsmaller command (see the doc in relsize.sty itself) 2) The nccmath package (from the ncctools bundle) has medium-sized math commands, which reduce the size by 20%, which is usually sufficient.

B.A.
noematic.logos
Posts: 19
Joined: Thu May 15, 2008 8:31 pm

Controlling font size in math mode

Post by noematic.logos »

Hi BA!

Thanks for the suggestions! I did try \mathsmaller but it didn't work very well. Because I use dcolumn to create new column type, every digit is treated separately :( so in order to get 0.66 to be consistent, I need:

Code: Select all

component &  \mathsmaller 0. \mathsmaller6 \mathsmaller6 & ... 
But this is toooooo small! I am going to try the second package you suggest. Thanks again.
Attachments
mathsmaller_result.pdf
output of mathsmaller compared to normal math sized text
(56.51 KiB) Downloaded 1049 times
noematic.logos
Posts: 19
Joined: Thu May 15, 2008 8:31 pm

Re: Controlling font size in math mode

Post by noematic.logos »

I couldn't get the nccmath package working. Its conflicting with another package, and I don't want to debug the file at this point to figure out what its mad at. Amsmath causes an error as well so something is grumpy. As a work around I forced the data to be the same size and switched back to normal column types.

I'd have to say this is one area where a WYSIWYG editor is a better solution than hand sculpting a document in latex...I don't have to debug my file to get it working, it may look bad, but at least it will print...
User avatar
Stefan Kottwitz
Site Admin
Posts: 10323
Joined: Mon Mar 10, 2008 9:44 pm

Controlling font size in math mode

Post by Stefan Kottwitz »

Hi noematic.logos,

a quick solution is provided by \everymath. In the following modification of your example I temporarily set \scriptstyle for all inline math, limit the effect by \begingroup ... \endgroup:

Code: Select all

\begingroup
\everymath{\scriptstyle}
\tiny
\ctable[
   caption=Title,
   pos=h
   ]{ld{1}{2}@{}d{1}{2}d{1}{2}@{}d{1}{2}d{1}{2}@{}d{1}{2}d{1}{2}@{}d{1}{2}d{1}{2}@{}d{1}{2}d{1}{2}@{}d{1}{2}}{%
}
{\FL
\multicolumn{1}{l}{Component} & \multicolumn{2}{c}{2} & \multicolumn{2}{c}{3} & \multicolumn{2}{c}{4} & \multicolumn{2}{c}{5} & \multicolumn{2}{c}{6} & \multicolumn{2}{c}{7} \ML
1. Component & 0.1 & 0.1 & 0.1 & 0.1 & 0.1 & 0.1 & 0.1 & 0.1 & 0.1 & 0.1 & 0.1 & 0.1          \NN
2. Component & & & & & & & & & & & &       \NN
3. Component & & & & & & & & & & & &        \NN
4. Component & & & & & & & & & & & &       \NN
5. Component & & & & & & & & & & & &        \NN
6. Component & & & & & & & & & & & &         \NN
7. Component & & & & & & & & & & & &          \LL
}
\endgroup
There are of course other ways, \everymath gives just a quick and easy solution.

Stefan
LaTeX.org admin
noematic.logos
Posts: 19
Joined: Thu May 15, 2008 8:31 pm

Re: Controlling font size in math mode

Post by noematic.logos »

Stefan...You.Are.The.Man!!!

That is awesome, I have no idea how that works, but it is WAY simpler than my solution of \relsize in front of every column definition.

Thank you very much!!
Post Reply