# Error “Output routine didn't use all of \box255.” using eskdx

win+miktex(the latest)+xelatex

MNWE

\documentclass[simple]{eskdtext}
\usepackage{tinos}
\usepackage{xecyr}
\usepackage{xunicode,xltxtra}
\providecommand{\No}{\textnumero}
\begin{document}
12345
\end{document}


I've faced the same problem with win+texlive2021 using pdflatex. In Win+texlive2020 there was no such problem.

eskdx draws stamps using the hook on \EveryShipout by means of package everyshi. I guess "very bad shape" on not straight lines in one of previous solutions is caused by some kind of recursion - shipout hook adds another hook, hook causes shipout and so on... Maybe I'm wrong here, I'm not sure.

There is another package with GOST stamps - eskd and it uses different approach. It draws stamps by means of fancyhdr, defining its own pagestyles and applying them.

I've tried to do the same with eskdx. Unfortunately, it's not enough to just renew one command, so I've copied the whole file eskdstamp.sty from texlive's .../tex/latex/eskdx/eskdstamp.sty to folder with my own styles (or to the folder with source .tex files). eskdstamp's file version is v0.98 in texlive2021.

After that, I had to make some changes to my copy of eskdstamp.sty file.

First, comment out (or delete) lines 988 and 1003 to disable pagestyle reset:

line 988:  %\pagestyle{empty}%
line 1003: %\thispagestyle{empty}%


Then modify lines 937-980 (from \RequirePackage{everyshi} to \EveryShipout{\ESKD@ShipoutPicture}) as shown below (I've left these lines commented here):

%\RequirePackage{everyshi}
\def\ESKD@curstyle{}
\def\ESKD@thisstyle{}
\def\ESKD@extra@Hook{}
\def\ESKD@extra@ThisHook{}
%% create new save box
\newsavebox{\ESKDFRAME}

\newcommand{\ESKD@ShipoutPicture}{%
\ifESKD@twoside
\ifodd\c@page
\ESKDframeX=\ESKD@margin@si
\else
\ESKDframeX=\ESKD@margin@so
\fi
\else
\ESKDframeX=\ESKD@margin@si
\fi
\ESKDframeY=\ESKD@margin@b
\ESKDstampX=\ESKDframeX
\ESKDstampY=\ESKDframeY
\savebox{\ESKDFRAME}(0,0){
\unitlength=1mm
\begin{picture}(0,0)(\ESKDltu{\ESKD@origin@x},\ESKDltu{\ESKD@origin@y})%
\ifx\ESKD@thisstyle\@empty
\let\ESKD@thisstyle\ESKD@curstyle
\fi
\loop
\ifnum \ESKD@hash@pos{@style@draw@\ESKD@thisstyle} %
< \ESKD@hash@count{@style@draw@\ESKD@thisstyle}
\ESKD@hash@next@value{@style@draw@\ESKD@thisstyle}\relax
\repeat
\global\let\ESKD@thisstyle\@empty%
\end{picture}}%
}

\RequirePackage{fancyhdr}
%% set "fancy" pagestyle and apply it for all pages as default
\pagestyle{fancy}
%% setup "fancy" pagestyle
\fancyhf{}
\unitlength=1mm
\begin{picture}(0,0)(0,0)
\ifthenelse{\equal{\ESKD@curstyle}{title}}{% for title page style
\ESKD@ShipoutPicture             % create saved box
\put(0,-12){\usebox{\ESKDFRAME}} % put saved
}{ % for any other page style
\ESKD@ShipoutPicture             % create saved box
\put(2,-7){\usebox{\ESKDFRAME}}  % put saved box
}
\end{picture}
}
%\EveryShipout{\ESKD@ShipoutPicture}


• It works, thank you. Apr 9 at 12:49
• Though it gives a lot of fancyhdr warnings now. Package fancyhdr Warning: \headheight is too small (0.0pt): (fancyhdr) Make it at least 17.0pt, for example: (fancyhdr) \setlength{\headheight}{17.0pt}. (fancyhdr) You might also make \topmargin smaller to compensate: (fancyhdr) \addtolength{\topmargin}{-17.0pt}. Package fancyhdr Warning: \footskip is too small (0.0pt): (fancyhdr) Make it at least 5.10005pt, for example: (fancyhdr) \setlength{\footskip}{5.10005pt}. Apr 10 at 22:11
• You may try to change those values. There is geometry setting at line 190 of the same file. Adjust values in that line: headheight=17pt,headsep=0mm,footskip=5.2pt]{geometry}. But it's not enough! After that you have to adjust last two \put directives in my code (lines 996, 999). First one should be \put(-0.18,-16.92){\usebox{\ESKDFRAME}} and the second one should be: \put(1.82,-11.92){\usebox{\ESKDFRAME}}. Apr 21 at 20:42

Something like this should (hopefully) redefine the shipout code in a safe way (based on code from Joseph). It assumes that a current latex is used. But it would be better if the class author would look at this. There are tons of files with redefinitions.

\documentclass[simple]{eskdtext}
\usepackage{xecyr}
\usepackage{xunicode,xltxtra}
\providecommand{\No}{\textnumero}
\makeatletter
\newsavebox\ESKDpicturebox

\renewcommand{\ESKD@ShipoutPicture}{%
\ifESKD@twoside
\ifodd\c@page
\ESKDframeX=\ESKD@margin@si
\else
\ESKDframeX=\ESKD@margin@so
\fi
\else
\ESKDframeX=\ESKD@margin@si
\fi
\ESKDframeY=\ESKD@margin@b
\ESKDstampX=\ESKDframeX
\ESKDstampY=\ESKDframeY
\sbox\ESKDpicturebox{%
\unitlength=1mm
\begin{picture}(0,0)(\ESKDltu{\ESKD@origin@x},\ESKDltu{\ESKD@origin@y})%
\ifx\ESKD@thisstyle\@empty
\let\ESKD@thisstyle\ESKD@curstyle
\fi
\loop
\ifnum \ESKD@hash@pos{@style@draw@\ESKD@thisstyle} %
< \ESKD@hash@count{@style@draw@\ESKD@thisstyle}
\ESKD@hash@next@value{@style@draw@\ESKD@thisstyle}\relax
\repeat
\ifx\ESKD@extra@ThisHook\@empty%
\ESKD@extra@Hook\else\ESKD@extra@ThisHook%
\fi%
\global\let\ESKD@thisstyle\@empty%
\global\let\ESKD@extra@ThisHook\@empty%
\end{picture}
}%
\put(1in,-1in){\usebox\ESKDpicturebox}}%
}

\makeatother
\begin{document}

12345
\end{document}


• While this fixes original problem, a new one arises. The rendered text in those frames (e.g. at the bottom) has very bad shape now. It has "steps" on every not straight line. Is it possible to address this as well? Mar 18 at 22:47

The class is setting box 255 globally, but that is not supposed to happen:

\documentclass[simple]{eskdtext}
\usepackage{xecyr}
\usepackage{xunicode,xltxtra}
\providecommand{\No}{\textnumero}
\makeatletter
\renewcommand{\ESKD@ShipoutPicture}{%
\bgroup
\ifESKD@twoside
\ifodd\c@page
\ESKDframeX=\ESKD@margin@si
\else
\ESKDframeX=\ESKD@margin@so
\fi
\else
\ESKDframeX=\ESKD@margin@si
\fi
\ESKDframeY=\ESKD@margin@b
\ESKDstampX=\ESKDframeX
\ESKDstampY=\ESKDframeY
\unitlength=1mm
\setbox\@cclv\vbox{%
\vbox{\let\protect\relax
\begin{picture}(0,0)(\ESKDltu{\ESKD@origin@x},\ESKDltu{\ESKD@origin@y})%
\ifx\ESKD@thisstyle\@empty
\let\ESKD@thisstyle\ESKD@curstyle
\fi
\loop
\ifnum \ESKD@hash@pos{@style@draw@\ESKD@thisstyle} %
< \ESKD@hash@count{@style@draw@\ESKD@thisstyle}
\ESKD@hash@next@value{@style@draw@\ESKD@thisstyle}\relax
\repeat
\ifx\ESKD@extra@ThisHook\@empty%
\ESKD@extra@Hook\else\ESKD@extra@ThisHook%
\fi%
\global\let\ESKD@thisstyle\@empty%
\global\let\ESKD@extra@ThisHook\@empty%
\end{picture}}%
\nointerlineskip%
\box\@cclv}%
\egroup
}
\makeatother
\begin{document}

12345
\end{document}


(I've simply removed a \global.)

• On win+miktex the pdf output with this change does not contain frame around the page. If I enter your code on overleaf (texlive) there is completely no output (also add \usepackage{tinos}). You can check my original example there - page is fine, frames are there. Mar 17 at 16:51