663
663
% the initialization macros executed before the table environments
664
664
% their scope is limited by a wrapper "savenotes" environment
665
665
%
666
- % 0) color support is enacted via adding code to four hooks:
666
+ % 0) color support is enacted via adding code to three hooks:
667
667
% - \sphinxtabletoprulehook (implicit from \sphinxtoprule expansion)
668
- % - \sphinxtableclinehook (implicit from \sphinxcline expansion)
669
668
% - \sphinxtableatstartofbodyhook (explicit from table templates)
670
669
% - \sphinxtableafterendhook (explicit from table templates)
671
- %
672
- % 1) we manage these four hooks in a way allowing a custom user extra wrapper
673
- % cenvironment from a container class to use them as entry point for some
674
- % custom code. The container code is done first, prior to table templates. So,
675
- % the style macros will *prepend* the needed color-code to the existing custom
676
- % user code, so the custom user code can override them. The custom user code
677
- % should not redefine any of the 3 \sphinxtable...hook macros via a
670
+ % additionally special adjustment must be made in \sphinxcline
671
+ %
672
+ % 1) we manage these three hooks in a way allowing a custom user extra wrapper
673
+ % environment from a container class to use them as entry point for some
674
+ % custom code. The container code is done first, prior to table templates.
675
+ % So, the style macros will *prepend* the needed color-code to the existing
676
+ % custom user code, so the custom user code can override them. The custom
677
+ % user code should not redefine any of the 3 \sphinxtable...hook macros via a
678
678
% \global\def, but their contents can use \gdef if this is the user intention,
679
679
% (attention that the hooks are executed from inside the table, except the
680
- % afterend hook so probably the code in-there should use \noalign),
680
+ % afterend hook so probably the code in-there should use \noalign),
681
681
%
682
682
% 2) the table templates and LaTeX writer code make it so that only
683
683
% one of either
693
693
% if it was already executed before as it self-annihilates).
694
694
695
695
\let\sphinxtabletoprulehook \@ empty
696
- \let\sphinxtableclinehook \@ empty
697
696
\let\sphinxtableatstartofbodyhook\@ empty
698
697
\let\sphinxtableafterendhook \@ empty
699
698
839
838
% this macro is needed in color tables as each \cline or \cmidrule (booktabs)
840
839
% consumes one \cr, offsetting the rownum parity.
841
840
\def\spx @table@@decrementrownum{\noalign {\global\advance\rownum\m@ne }}
842
-
841
+ \let\sphinxtabledecrementrownum\@ empty
843
842
844
843
% At last the style macros
845
844
846
845
% \spx@toprule is what the styles define; the colorrows class will prepend
847
846
% some code in \sphinxtabletoprulehook
848
847
\def\sphinxtoprule {\spx@toprule\sphinxtabletoprulehook }
849
- % \spx@cline is what the styles define; the colorrows class will prepend
850
- % some code in \sphinxtableclinehook. This hook is located first due
851
- % to constraint of the booktabs \cmidrule.
852
- \def\sphinxcline {\sphinxtableclinehook\spx@cline }
853
848
854
849
% standard style
855
850
\def\sphinxthistablewithstandardstyle {%
856
851
% Those two are produced by the latex writer
857
852
\def\sphinxhline {\hline }%
858
- \def\spx@cline {\cline }%
853
+ % \sphinxtabledecrementrownum is a no-op which is redefined by colorrows
854
+ % to correct the \rownum increment induced by \cline in colorrows regime
855
+ \def\sphinxcline {\sphinxtabledecrementrownum\cline }%
859
856
% Those three are inserted by the table templates
860
857
\def\spx@toprule {\hline }%
861
858
\def\sphinxmidrule {\hline }%
890
887
\def\sphinxbooktabsmidrule {\midrule }
891
888
\def\sphinxbooktabsbottomrule {\bottomrule }
892
889
\let\sphinxbooktabscmidrule \@ gobble % i.e. draw no short rules at all!
890
+ % You can redefine this to use \cmidrule with various options, such
891
+ % as \cmidrule(lr), but:
892
+ % Attention, if you want this to use \cmidrule (or \cline) you must
893
+ % also include the \sphinxtabledecrementrownum token like e.g. this
894
+ % \def\sphinxbooktabscmidrule{\sphinxtabledecrementrownum\cmidrule}
895
+ % and it must be first due to internals of the \cmidrule usage of \futurelet,
896
+ % if the table uses row colours.
893
897
894
898
\def\sphinxthistablewithbooktabsstyle {%
895
899
\let\sphinxhline\@empty % there is no wrapper macro here so if you want to change that
896
900
% you will have to redefine \sphinxthistablewithbooktabsstyle
897
- \def\spx@cline {\sphinxbooktabscmidrule }% defaults to \@gobble
901
+ \def\sphinxcline {\sphinxbooktabscmidrule }% defaults to \@gobble
898
902
\def\spx@toprule {\sphinxbooktabstoprule }%
899
903
\def\sphinxmidrule {\sphinxbooktabsmidrule }%
900
904
\def\sphinxbottomrule {\sphinxbooktabsbottomrule }%
@@ -916,7 +920,7 @@ to allow local use of booktabs table style}%
916
920
% borderless style
917
921
\def\sphinxthistablewithborderlessstyle {%
918
922
\let\sphinxhline \@empty
919
- \let\spx@cline \@gobble
923
+ \let\sphinxcline \@gobble
920
924
\let\spx@toprule \@empty
921
925
\let\sphinxmidrule \@empty
922
926
\let\sphinxbottomrule \@empty
@@ -937,10 +941,9 @@ to allow local use of booktabs table style}%
937
941
%
938
942
\let\spx@table@toprulehook \spx@table@@toprulehook
939
943
\let\spx@table@startbodycolorrows \spx@table@@startbodycolorrows
940
- \let\spx@table@decrementrownum \spx@table@@decrementrownum
944
+ \let\sphinxtabledecrementrownum \spx@table@@decrementrownum
941
945
\spx@prepend\spx@table@toprulehook \to\sphinxtabletoprulehook
942
946
\spx@prepend\spx@table@startbodycolorrows\to\sphinxtableatstartofbodyhook
943
- \spx@prepend\spx@table@decrementrownum \to\sphinxtableclinehook
944
947
%
945
948
% this one is not set to \@empty by norowcolors, because it looks harmless
946
949
% to execute it always, as it simply resets to standard colortbl state after
@@ -958,10 +961,11 @@ to allow local use of booktabs table style}%
958
961
% simply make it no-op, without even checking if really it was activated.
959
962
\let\spx@table@toprulehook \@empty
960
963
\let\spx@table@startbodycolorrows\@empty
961
- \let\spx@table@decrementrownum \@empty
964
+ \let\sphinxtabledecrementrownum \@empty
962
965
% we don't worry about \sphinxtableafterendhook as the \spx@table@resetcolortbl
963
966
% done at end can not do harm; and also we could have not bothered with the
964
- % \spx@table@decrementrownum as its action is harmless
967
+ % \sphinxtabledecrementrownum as its \rownum decrement, if active, is harmless
968
+ % in non-colorrows context
965
969
}
966
970
967
971
% The \sphinxarrayrulewidth is used for some complex matters of merged
0 commit comments