TransWikia.com

Custom font size in a math aligned environment

TeX - LaTeX Asked by user15032172 on April 26, 2021

I am fairly new to LaTeX and I need help in finding a way to increase the font size in a math aligned environment.

documentclass[10pt]{article}
usepackage{amsmath}
usepackage{relsize} 

newcommand{eq}[1]{begin{align*}
    #1
    end{align*}}


begin{document}

eq{
fontsize{20}{20}
    &F=ky
    &W = frac{1}{2}ky^2
}


end{document}

I have tried using the large and the fontsize{}{} command and it has not worked. I would be greatful if someone could help me out in ajusting the font size of my equations. Ideally I would like a solution where I can enter another parameter into my eq command to control the font size.

One Answer

enter image description here

This is an unconventional solution which uses the fontsize package. We define the new environment myalign* with an optional argument which takes one of the font sizing commands provided by fontsize. This should be sufficient for most concrete cases.

documentclass[10pt]{article}
usepackage{lmodern}
usepackage{amsmath}
usepackage[fontsize=10pt]{fontsize} 

makeatletter
newenvironment{myalign*}[1][]{%
 csname#1endcsname
 start@align@nest@rredtruem@ne
}{%
 endalign
}
makeatother

begin{document}

Normal size 

begin{myalign*}
 &F=ky
 &W = frac{1}{2}ky^2
end{myalign*}

begin{myalign*}[normalsizer]
&F=ky
&W = frac{1}{2}ky^2
end{myalign*}

begin{myalign*}[normalsizerr]
 &F=ky
 &W = frac{1}{2}ky^2
end{myalign*}

begin{myalign*}[normalsizerrr]
 &F=ky
 &W = frac{1}{2}ky^2
end{myalign*}

begin{myalign*}[Larger]
 &F=ky
 &W = frac{1}{2}ky^2
end{myalign*}
 
 Normal size
 
end{document}

If you want full control over the font and the line spacing you will need something similar:

makeatletter
newenvironment{xmyalign*}[2]{%
 fontsize{#1}{#2}selectfont
 start@align@nest@rredtruem@ne
}{%
 endalign
}
makeatother

To use, for example, like this:

begin{xmyalign*}{60}{60}
 &F=ky
 &W = frac{1}{2}ky^2
end{xmyalign*}

Correct answer by Ivan on April 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP