% \iffalse %% %% (C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley %% All rights reserved. %% %% Not for general distribution. In its present form it is not allowed %% to put this package onto CD or an archive without consulting the %% the authors. %% % \fi % % \begin{macrocode} \def\@tempa#1: #2.dtx,v #3 #4 #5 #6 #7${ \ProvidesPackage{#2}[#4 #3 #5 #6]} \@tempa$Id: xo-grid.dtx,v 1.3 2000/08/11 07:14:20 latex3 Exp $ % \end{macrocode} % % Ignore white space in this package. % \begin{macrocode} \IgnoreWhiteSpace % \end{macrocode} % % This package implements grid design on top of \LaTeXe{} by adding % |\AlignToGrid| in various macros. Nothing else is really needed (or % so I hope :-) % % So far this probably doesn't cover all structures that should, or % could be handled automatically. % % \subsection{Headings} % % % \begin{macro}{\headingsinkage} % This is a temporary register used to specify the amount of % sinkage a |\@startsection| heading is allowed if it falls at the % a column break. In a proper reimplementation of |\@startsection| % as a template, this should be individually specifiable rather % than being the same for all headings! % \begin{macrocode} \newskip\headingsinkage \headingsinkage=5pt plus 3pt minus 5pt % \end{macrocode} % \end{macro} % % \begin{macro}{\@startsection} % \begin{macrocode} \def\@startsection#1#2#3#4#5#6{% \if@noskipsec \leavevmode \fi \par \@tempskipa #4\relax \@afterindenttrue \ifdim \@tempskipa <\z@ \@tempskipa -\@tempskipa \@afterindentfalse \fi \if@nobreak \everypar{}% \else \addpenalty\@secpenalty \addvspace\@tempskipa % \end{macrocode} % next lines are pretty horrible but we need something like this % here (only it could be be done better) % \begin{macrocode} \vskip-\headingsinkage \vskip\saved@topskip \vskip-\prevdepth \nointerlineskip \null \nobreak \vskip-\saved@topskip \vskip\headingsinkage \fi \@ifstar {\@ssect{#3}{#4}{#5}{#6}}% {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}} % \end{macrocode} % \end{macro} % % % % % \begin{macro}{\@sect} % Have to ensure that we don't get the heading itself aligned due % to a dangling |\AlignToGrid| from a previous structure, so we % issue a |\IgnoreAlignToGrid| early on. That's the only change for % this command. % \begin{macrocode} \def\@sect#1#2#3#4#5#6[#7]#8{% \ifnum #2>\c@secnumdepth \let\@svsec\@empty \else \refstepcounter{#1}% \protected@edef\@svsec{\@seccntformat{#1}\relax}% \fi \@tempskipa #5\relax \IgnoreAlignToGrid \ifdim \@tempskipa>\z@ \begingroup #6{% \@hangfrom{\hskip #3\relax\@svsec}% \interlinepenalty \@M #8\@@par}% \endgroup \csname #1mark\endcsname{#7}% \addcontentsline{toc}{#1}{% \ifnum #2>\c@secnumdepth \else \protect\numberline{\csname the#1\endcsname}% \fi #7}% \else \def\@svsechd{% #6{\hskip #3\relax \@svsec #8}% \csname #1mark\endcsname{#7}% \addcontentsline{toc}{#1}{% \ifnum #2>\c@secnumdepth \else \protect\numberline{\csname the#1\endcsname}% \fi #7}}% \fi \@xsect{#5}} % \end{macrocode} % \end{macro} % % % % % \begin{macro}{\@xsect} % Now after having typeset the heading we need to issue % |\ObeyAlignToGrid| and make sure that the first line of text gets % aligned again. And in addition we issue a |\AlignToGrid| inside % the |\everypar| to align the first text after the heading. Of % course that mean that we will generate a break point after this % line and thus might end up up with a heading and only a single % line afterwards. % % This could be fixed by using a ``rspace'' structure as % implemented in \texttt{xo-or.sty} but this is not added at the % moment! % \begin{macrocode} \def\@xsect#1{% \ObeyAlignToGrid \@tempskipa #1\relax \ifdim \@tempskipa>\z@ \par \nobreak \vskip \@tempskipa \@afterheading \else \@nobreakfalse \global\@noskipsectrue \everypar{% \if@noskipsec \global\@noskipsecfalse {\setbox\z@\lastbox}% \clubpenalty\@M \AlignToGrid \begingroup \@svsechd \endgroup \unskip \@tempskipa #1\relax \hskip -\@tempskipa \else \clubpenalty \@clubpenalty \everypar{}% \fi}% \fi \ignorespaces} % \end{macrocode} % \end{macro} % % % % % % \begin{macro}{\@afterheading} % The other case where we have to add |\AlignToGrid| to the % |\everypar|. % \begin{macrocode} \def\@afterheading{% \@nobreaktrue \everypar{% \if@nobreak \@nobreakfalse \clubpenalty \@M \if@afterindent \else {\setbox\z@\lastbox}% \fi \AlignToGrid \else \clubpenalty \@clubpenalty \everypar{}% \fi}} % \end{macrocode} % \end{macro} % % % \subsection{List structures} % % \begin{macro}{\@doendpe} % Handling of |\everypar| after a list strcture is already strange % and complicated; here we complicate it even more by adding % |\AlignToGrid| into its definition(s). % \begin{macrocode} \def\@doendpe{\@endpetrue \def\par{\@restorepar \everypar{\everypar{}\AlignToGrid}\par\@endpefalse}% \everypar{{\setbox\z@\lastbox}\everypar{}\AlignToGrid\@endpefalse}% } % \end{macrocode} % \end{macro} % % % % % % \begin{macro}{\endtrivlist} % And there is one case in |\endtrivlist| in which |\@doendpe| % is skipped so we have to set |\everypar| manually % here.\footnote{Perhaps done in a wrong way, CHECK!} % \begin{macrocode} \def\endtrivlist{% \if@inlabel \leavevmode \global \@inlabelfalse \fi \if@newlist \@noitemerr \global \@newlistfalse \fi \ifhmode\unskip \par\fi \if@noparlist \everypar{\everypar{}\AlignToGrid} \else \ifdim\lastskip >\z@ \@tempskipa\lastskip \vskip -\lastskip \advance\@tempskipa\parskip \advance\@tempskipa -\@outerparskip \vskip\@tempskipa \fi \@endparenv \fi } % \end{macrocode} % \end{macro} % % % \subsection{Math} % % \begin{macro}{\displaymath} % \begin{macro}{\enddisplaymath} % \begin{macro}{\[} % \begin{macro}{\]} % Math is a bit more complicated as with the standard definitions % we don't regain control after the display. So we change all the % definitions to use the |\@doendpe| method. This means we have to % redefine |\[| at al to be a ref to |\displaymath| not the other % way around as it was done in \texttt{latex.ltx}. % \begin{macrocode} \def \displaymath { \relax\ifmmode \@badmath \else \ifvmode \nointerlineskip \makebox[.6\linewidth]% \fi $$%%$$ BRACE MATCH HACK \fi } \def \enddisplaymath { \relax\ifmmode \ifinner \@badmath \else $$%%$$ BRACE MATCH HACK \fi \else \@badmath \fi % \end{macrocode} % To gain control we end the paragraph and then invoke the |\end| % mechanism for dealing with par. This gives in certain situations % slightly different results compared working only with |$$|'s but % that's life. % \begin{macrocode} \par \@endpetrue % kill parindent if current paragraph continues \@ignoretrue } \def\[{\begin{displaymath}} \def\]{\end{displaymath}} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % % % % % \begin{macro}{\endequation} % Same change for the end of an equation. % \begin{macrocode} \def\endequation{\eqno \hbox{\@eqnnum}$$\par\@ignoretrue \@endpetrue % kill parindent if current paragraph continues } % \end{macrocode} % \end{macro} % % % % \begin{macro}{\endeqnarray} % And again the same for the equation array structure. % \begin{macrocode} \def\endeqnarray{% \@@eqncr \egroup \global\advance\c@equation\m@ne $$\par\@ignoretrue \@endpetrue % kill parindent if current paragraph continues } % \end{macrocode} % \end{macro} % % \endinput \endinput % % $Log: xo-grid.dtx,v $ % Revision 1.3 2000/08/11 07:14:20 latex3 % added header % % Revision 1.2 2000/08/06 19:01:12 latex3 % fix \prevdepth situation before \@startsection % % Revision 1.1 2000/07/30 18:07:22 latex3 % Initial revision % % % % % % % % \begin{macro}{} % \begin{macrocode} % \end{macrocode} % \end{macro}