Skip to content

Instantly share code, notes, and snippets.

@adityam
Created November 14, 2013 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adityam/faec6dddbead33202320 to your computer and use it in GitHub Desktop.
Save adityam/faec6dddbead33202320 to your computer and use it in GitHub Desktop.
\unprotect
\unexpanded\def\page_sides_check_floats_set
{\scratchdimen\dimexpr\d_page_sides_progress-\roundingeps\relax
\c_page_sides_n_of_hang\scratchdimen
\divide\c_page_sides_n_of_hang \baselineskip\relax
\ifnum\c_page_sides_n_of_hang>\zerocount
% new from here (needs test case, old code)
\ifcase\c_page_sides_n_of_lines
\else
\ifcase\c_page_sides_lines_done
\global\c_page_sides_lines_done\c_page_sides_n_of_hang
\else
\scratchcounter\c_page_sides_lines_done
\advance\scratchcounter-\c_page_sides_n_of_hang
\global\advance\c_page_sides_n_of_lines-\scratchcounter
\fi
\fi
% hm, when do we get the parshape branch? needs testing
\ifnum\c_page_sides_n_of_lines>\zerocount
\scratchtoks\emptytoks
\scratchcounter\c_page_sides_n_of_lines
\scratchdimen\dimexpr\hsize-\d_page_sides_width\relax
\dorecurse\c_page_sides_n_of_lines
{\appendtoks \zeropoint \hsize \to \scratchtoks}%
\ifnum\c_page_sides_n_of_hang>\c_page_sides_n_of_lines
\advance\c_page_sides_n_of_hang -\c_page_sides_n_of_lines\relax
\advance\scratchcounter\c_page_sides_n_of_hang
\dorecurse\c_page_sides_n_of_hang % weird, shouldn't that be scratchcounter
{\ifnum\c_page_sides_float_type>\plusfour
\appendtoks \zeropoint \scratchdimen \to \scratchtoks
\else
\appendtoks \d_page_sides_width\scratchdimen \to \scratchtoks
\fi}%
\fi
\parshape
\numexpr\scratchcounter+\plusone\relax
\the\scratchtoks % \scratchcounter
\zeropoint \hsize % \plusone
\relax
\else
% new till here
\hangindent \ifnum\c_page_sides_float_type>\plusfour -\fi\d_page_sides_width
\hangafter-\c_page_sides_n_of_hang
\fi
\fi
\global\advance\c_page_sides_checks_done \plusone
\iftracesidefloats
\hskip-\d_page_sides_width % kern
\color[darkgray]%
{\vrule\s!height.5\points\s!depth.5\points\s!width\d_page_sides_width
\llap{\showstruts\strut\kern.25\bodyfontsize}}%
\fi}
\protect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment