Skip to content

Commit

Permalink
Fix vertical alignment with multiple subcircuits
Browse files Browse the repository at this point in the history
Previously, they might cancel out each other in very particular and unpredictable circumstances - but now, we'll possibly need more resources.
  • Loading branch information
projekter committed Jan 22, 2023
1 parent ffee786 commit 4a2384a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
Binary file modified doc/latex/yquant/yquant-doc.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions doc/latex/yquant/yquant-doc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -5357,5 +5357,6 @@

\subsection*{2023-01-21: Version 0.7.3}
Fix \href{https://github.com/projekter/yquant/issues/24}{\#24}: Clipping in subcircuits can under very special circumstances fail. Change all clipping paths to a most conservative huge rectangle---before, we tried to be economical.
Also use a more meticulous way of subcircuit position alignment (which will probably consume more resources during compilation, but multiple subcircuits may cancel each other in height and depth calculation if we don't do it).
%END_FOLD
\end{document}
28 changes: 16 additions & 12 deletions tex/latex/yquant/yquant-env.tex
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,9 @@
\listremove\noexpand\redolist{#1}%
\expandafter\noexpand\csname yquant@env@end@calcypositions@#1@\i\endcsname%
\expandafter\unless\expandafter\ifx\csname\yquant@prefix subcircuits\endcsname\empty%
\ifinlist{#1}\noexpand\redolist{%
\noexpand\forlistloop%
\yquant@env@end@calcypositions@run%
\expandafter\noexpand\csname\yquant@prefix subcircuits\endcsname%
}{%
\noexpand\ifyquant@env@end@calcypositions@godeep%
\noexpand\forlistloop%
\yquant@env@end@calcypositions@run%
\expandafter\noexpand\csname\yquant@prefix subcircuits\endcsname%
\noexpand\fi%
}%
\noexpand\forlistloop%
\yquant@env@end@calcypositions@run%
\expandafter\noexpand\csname\yquant@prefix subcircuits\endcsname%
\fi%
}%
% END_FOLD
Expand Down Expand Up @@ -416,8 +408,20 @@
\csname yquant@env@end@calcypositions@#1\endcsname%
}

\protected\def\yquant@env@end@calcypositions@redo@min#1{%
\ifnum#1<\redoitem\space %
\def\redoitem{#1}%
\fi%
}

\protected\def\yquant@env@end@calcypositions@redo{%
\forlistloop\yquant@env@end@calcypositions@run\redolist%
% instead of looping through the list, we only check the lowest item - since running it may actually remove some other items from the list. Note that the lowest item is not necessarily the outermost, but for sure the topmost wire that should be redone is contained in it.
\unless\ifx\redolist\empty%
\def\redoitem{2147483647}%
\forlistloop\yquant@env@end@calcypositions@redo@min\redolist%
% this will automatically remove the item from the list
\expandafter\yquant@env@end@calcypositions@run\expandafter{\redoitem}%
\fi%
\unless\ifx\redolist\empty%
\expandafter\yquant@env@end@calcypositions@redo%
\fi%
Expand Down

0 comments on commit 4a2384a

Please sign in to comment.