File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -659,11 +659,23 @@ const processLongTableSidenotes = (latexLongTable: string) => {
659659 strOutput . push ( remainingStr ) ;
660660 }
661661 }
662- strOutput . push ( strProcessing ) ;
663662
663+ // Ensure that we inject sidenotes after the longtable
664+ const endTable = "\\end{longtable}" ;
665+ const endPos = strProcessing . indexOf ( endTable ) ;
666+ const prefix = strProcessing . substring ( 0 , endPos + endTable . length ) ;
667+ const suffix = strProcessing . substring (
668+ endPos + endTable . length ,
669+ strProcessing . length ,
670+ ) ;
671+
672+ strOutput . push ( prefix ) ;
664673 for ( const note of sidenotes ) {
665674 strOutput . push ( `\\sidenotetext{${ note } }\n` ) ;
666675 }
676+ if ( suffix ) {
677+ strOutput . push ( suffix ) ;
678+ }
667679
668680 return strOutput . join ( "" ) ;
669681} ;
@@ -683,7 +695,7 @@ const longTableSidenoteProcessor = () => {
683695 }
684696 case "capturing" :
685697 capturedLines . push ( line ) ;
686- if ( line . match ( / [ ^ \\ n ] \\ e n d { longtable} . * $ / ) ) {
698+ if ( line . match ( / \\ e n d { longtable} / ) ) {
687699 state = "scanning" ;
688700
689701 // read the whole figure and clear any capture state
You can’t perform that action at this time.
0 commit comments