TeX - LaTeX Asked on April 15, 2021
In the following mwe I’m redefining the equation*
environment to store the width of its contents in a token list:
documentclass{article}
usepackage{showframe}
usepackage[fleqn]{amsmath}
% from https://tex.stackexchange.com/a/59955/172923
makeatletter
newcommand{settowidthofalign}[2]{%
setboxz@=vbox{
begin{align*}
#2
ifmeasuring@elsegloballetgot@maxcolwdmaxcolumn@widthsfi
end{align*}
}%
begingroup
defor{+}edefx{endgroup#1=dimexprgot@maxcolwdrelax}x}
makeatother
ExplSyntaxOn
dim_new:N l_eqn_width_dim
cs_set_eq:cc { oldequation* }{ equation* }
cs_set_eq:cc { endoldequation* }{ endequation* }
RenewDocumentEnvironment{ equation* }{ +b }
{
settowidthofalign{ l_eqn_width_dim } { #1 }
begin{oldequation*} #1 end{oldequation*}
}{}
ExplSyntaxOff
begin{document}
begin{equation*}
(b_{n + 1}, e_m) = (v_{n + 1}, e_m) - sum_{j = 1}^{n} (v_{n + 1}, e_j) ,
(e_j, e_m) = (v_{n + 1}, e_m) - (v_{n + 1}, e_m)
end{equation*}
end{document}
however, when I run the code I get the warning
Overfull hbox (1.07913pt too wide) detected at line 37
even though the content of equation*
is clearly within the page margins:
I suspect the warning is not generated by equation*
itself, but by align*
, which is used in the settowidthofalign
macro. Indeed, commenting out
% settowidthofalign{ l_eqn_width_dim } { #1 }
gets rid of the warning. How can I fix this?
You don't see the overfull box as you are typesetting equation*
but internally using align*
the flush left implementation loses some shrinkability, if you remove the redefinitions and just set both forms then you see the same overfull box also output
documentclass{article}
usepackage{showframe}
usepackage[fleqn]{amsmath}
begin{document}
begin{equation*}
(b_{n + 1}, e_m) = (v_{n + 1}, e_m) - sum_{j = 1}^{n} (v_{n + 1}, e_j) ,
(e_j, e_m) = (v_{n + 1}, e_m) - (v_{n + 1}, e_m)
end{equation*}
align
begin{align*}
(b_{n + 1}, e_m) = (v_{n + 1}, e_m) - sum_{j = 1}^{n} (v_{n + 1}, e_j) ,
(e_j, e_m) = (v_{n + 1}, e_m) - (v_{n + 1}, e_m)
end{align*}
end{document}
Correct answer by David Carlisle on April 15, 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