TeX - LaTeX Asked by Robb1 on July 3, 2021
I would like to reduce the size of the following equation just exactly as needed in order to fit the page. Is there some sort of command to adapt the font size to the page width?
Here’s my latex:
begin{equation}
dleft(begin{array}{c}
D(t) Pi(t) Theta(t)
end{array}right)
=
left(begin{array}{ccc}
-alpha_{D} & 1 & 0
0 & -alpha_{Pi} & 0
0 & 0 & -alpha_{Theta}
end{array}right)
left(begin{array}{c}
D(t) Pi(t) Theta(t)
end{array}right)
+
left(begin{array}{ccc}
sigma_{D,D} & sigma_{D,Pi} & 0
0 & sigma_{Pi,Pi}& 0
sigma_{Theta,D} & 0 & sigma_{Theta,Theta}
end{array}right)
d left(begin{array}{c}
w_{D}(t) w_{Pi}(t) w_{Theta}(t)
end{array}right)
end{equation}
And here’s the result I get (as you can see the equation gets out of the right page bound):
Note: I tried using
resizebox{.9 textwidth}{!}
{
begin{equation}
[...] % My equation here
end{equation}
}
But I get a compilation error.
As others have said it is best to avoid scaling. In this case you can most likely make it fit on one line without scaling. You are loading amsmath
but not using its matrix environments which means that you have a lot more space around the large brackets than needed. That change and a small squeezing of the column spacing is all you need to make things fit here:
documentclass[a4paper]{article}
addtolengthtextwidth{10mm}% try to get initial position like image shown No test file provided :(((
usepackage{amsmath}
begin{document}
original
begin{equation}
dleft(begin{array}{c}
D(t) Pi(t) Theta(t)
end{array}right)
=
left(begin{array}{ccc}
-alpha_{D} & 1 & 0
0 & -alpha_{Pi} & 0
0 & 0 & -alpha_{Theta}
end{array}right)
left(begin{array}{c}
D(t) Pi(t) Theta(t)
end{array}right)
+
left(begin{array}{ccc}
sigma_{D,D} & sigma_{D,Pi} & 0
0 & sigma_{Pi,Pi}& 0
sigma_{Theta,D} & 0 & sigma_{Theta,Theta}
end{array}right)
d left(begin{array}{c}
w_{D}(t) w_{Pi}(t) w_{Theta}(t)
end{array}right)
end{equation}
ams matrices
begin{equation}setlengtharraycolsep{4pt}
dbegin{pmatrix}
D(t) Pi(t) Theta(t)
end{pmatrix}
=
begin{pmatrix}
-alpha_{D} & 1 & 0
0 & -alpha_{Pi} & 0
0 & 0 & -alpha_{Theta}
end{pmatrix}
begin{pmatrix}
D(t) Pi(t) Theta(t)
end{pmatrix}
+
begin{pmatrix}
sigma_{D,D} & sigma_{D,Pi} & 0
0 & sigma_{Pi,Pi}& 0
sigma_{Theta,D} & 0 & sigma_{Theta,Theta}
end{pmatrix}
d begin{pmatrix}
w_{D}(t) w_{Pi}(t) w_{Theta}(t)
end{pmatrix}
end{equation}
end{document}
Correct answer by David Carlisle on July 3, 2021
It is never a good solution to start adjusting the font size of math, (1) it gives an inconsistent design, and (2) hurts readability. Instead learn to break mathematics it will become an important tool in your future documents.
documentclass[a4paper]{article}
usepackage{amsmath}
begin{document}
begin{equation}
begin{aligned}
dbegin{pmatrix}{c} D(t) Pi(t) Theta(t)
end{pmatrix}
= {} & % note the {} in front of & in this case
begin{pmatrix}
-alpha_{D} & 1 & 0
0 & -alpha_{Pi} & 0
0 & 0 & -alpha_{Theta}
end{pmatrix}
begin{pmatrix}
D(t) Pi(t) Theta(t)
end{pmatrix}
& +
begin{pmatrix}
sigma_{D,D} & sigma_{D,Pi} & 0
0 & sigma_{Pi,Pi}& 0
sigma_{Theta,D} & 0 & sigma_{Theta,Theta}
end{pmatrix}
d begin{pmatrix} w_{D}(t) w_{Pi}(t) w_{Theta}(t)
end{pmatrix}
end{aligned}
end{equation}
end{document}
here I've also used the pmatrix
env as it gives less typing.
Note also how I provide a full minimal example including document class and appropriate preamble. This makes it a lot easier for others to test the code.
Answered by daleif on July 3, 2021
The environment of choice for this case is multline
.
documentclass{article}
usepackage{amsmath}
begin{document}
begin{multline}
dbegin{pmatrix}
D(t) Pi(t) Theta(t)
end{pmatrix}
=
begin{pmatrix}
-alpha_{D} & 1 & 0
0 & -alpha_{Pi} & 0
0 & 0 & -alpha_{Theta}
end{pmatrix}
begin{pmatrix}
D(t) Pi(t) Theta(t)
end{pmatrix}
+
begin{pmatrix}
sigma_{D,D} & sigma_{D,Pi} & 0
0 & sigma_{Pi,Pi}& 0
sigma_{Theta,D} & 0 & sigma_{Theta,Theta}
end{pmatrix}
d begin{pmatrix}
w_{D}(t) w_{Pi}(t) w_{Theta}(t)
end{pmatrix}
end{multline}
end{document}
Note the usage of pmatrix
.
The objection that this doesn't directly answer the question should be rejected, but it's not difficult to make an example so you can judge for yourself.
documentclass{article}
usepackage{amsmath}
usepackage{graphicx}
newenvironment{scaledequation}
{begin{equation}begin{lrbox}{scaledequationbox}$displaystyle}
{$end{lrbox}%
resizebox{0.9displaywidth}{!}{usebox{scaledequationbox}}%
end{equation}
ignorespacesafterend}
newsavebox{scaledequationbox}
begin{document}
This is how a long equation should be treated when it's too wide for
fitting the given text width
begin{multline}
dbegin{pmatrix}
D(t) Pi(t) Theta(t)
end{pmatrix}
=
begin{pmatrix}
-alpha_{D} & 1 & 0
0 & -alpha_{Pi} & 0
0 & 0 & -alpha_{Theta}
end{pmatrix}
begin{pmatrix}
D(t) Pi(t) Theta(t)
end{pmatrix}
+
begin{pmatrix}
sigma_{D,D} & sigma_{D,Pi} & 0
0 & sigma_{Pi,Pi}& 0
sigma_{Theta,D} & 0 & sigma_{Theta,Theta}
end{pmatrix}
d begin{pmatrix}
w_{D}(t) w_{Pi}(t) w_{Theta}(t)
end{pmatrix}
end{multline}
On the other hand, you could rescale the material to fit, with a
dubious result, which you can compare to the previous one
begin{scaledequation}
dbegin{pmatrix}
D(t) Pi(t) Theta(t)
end{pmatrix}
=
begin{pmatrix}
-alpha_{D} & 1 & 0
0 & -alpha_{Pi} & 0
0 & 0 & -alpha_{Theta}
end{pmatrix}
begin{pmatrix}
D(t) Pi(t) Theta(t)
end{pmatrix}
+
begin{pmatrix}
sigma_{D,D} & sigma_{D,Pi} & 0
0 & sigma_{Pi,Pi}& 0
sigma_{Theta,D} & 0 & sigma_{Theta,Theta}
end{pmatrix}
d begin{pmatrix}
w_{D}(t) w_{Pi}(t) w_{Theta}(t)
end{pmatrix}
end{scaledequation}
I have no doubt whatsoever as to which one I'd choose.
end{document}
Answered by egreg on July 3, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP