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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ay3NRtLtypuStJdysepuJU
This commit is contained in:
Andreas Richardson 2026-09-29 23:28:23 +01:00
commit 24249dfd2e
2 changed files with 4 additions and 1 deletions

View file

@ -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<i>@def" (by default "p{\cvcolumnautowidth}"), separated by "@{\hspace*{\separatorcolumnwidth}}"
% - the tabular heading is the aggregation of the different "\cvcolumn<i>@head", separated by "&"