From 24249dfd2e87341cebeef0f56e5d85bfce4e8c26 Mon Sep 17 00:00:00 2001 From: Andreas Richardson Date: Tue, 29 Sep 2026 23:28:23 +0100 Subject: [PATCH] Fix arithmetic overflow in cvcolumns when all columns set a width (#311) The width left for columns without an explicit width was divided by their count even when that count was zero, so a cvcolumns environment whose columns all set a width stopped with "Arithmetic overflow" at \end{cvcolumns}. Only share the remaining width when some column has none. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Ay3NRtLtypuStJdysepuJU --- CHANGELOG | 1 + moderncv.cls | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 50ddd43..f9d2f91 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ version next - Fix "Underfull \hbox (badness 10000)" warning in banking \subsection dotted rules by adding \hss glue as in \dotfill (#307) - Update "circle" option to allow for half-filled circles in skill matrix (#309) +- Fix "Arithmetic overflow" in cvcolumns when every column sets a width (#311) version 2.6.1 (24 Jun 2026) - Allow the customisation of the contemporary style (#297) diff --git a/moderncv.cls b/moderncv.cls index 1bc93cf..1f02b2a 100644 --- a/moderncv.cls +++ b/moderncv.cls @@ -676,7 +676,9 @@ % compute the width of each cvcolumn, considering a spacing of \separatorcolumnwidth and the columns with set width \ifnum\thecvcolumnscounter>0% \setlength{\cvcolumnswidth}{\maincolumnwidth-\value{cvcolumnscounter}\separatorcolumnwidth+\separatorcolumnwidth}% - \setlength{\cvcolumnautowidth}{\cvcolumnswidth*\ratio{\cvcolumnsautowidth}{\cvcolumnsdummywidth}/\value{cvcolumnsautowidthcounter}}\fi% + % only share the remaining width if some columns have no explicit width, to avoid a division by zero ("Arithmetic overflow") when all have one + \ifnum\value{cvcolumnsautowidthcounter}>0% + \setlength{\cvcolumnautowidth}{\cvcolumnswidth*\ratio{\cvcolumnsautowidth}{\cvcolumnsdummywidth}/\value{cvcolumnsautowidthcounter}}\fi\fi% % pre-aggregate the tabular definition, heading and content (required before creating the tabular, as the tabular environment doesn't like loops --- probably because "&" generates a \endgroup) % - the tabular definition is the aggregation of the different "\cvcolumn@def" (by default "p{\cvcolumnautowidth}"), separated by "@{\hspace*{\separatorcolumnwidth}}" % - the tabular heading is the aggregation of the different "\cvcolumn@head", separated by "&"