% % tab-form.sty % % This is part of the TeSLa package that is the subject of the paper % entitled "An Example Special Purpose Input Language to LaTeX" that % was (will be) presented to the TUG94 conference in Santa Barabara. % % Please see tesla.sty for more details. % ====================================== % % % Customization Required for [tvar. % ================================= % % The tabular form is the first "form" used by TeSLa. That is, the % English form (the second "form") is ignored when the tabular form is % used. This is implemented with the \xform command, whose arguments % are: % #1 - The tabular form % #2 - The English form; IGNORED in this style % % See the "The [tvar command" subsection of "The Implementation" section % in the paper for more details. % \gdef\xform#1#2{#1} % % Customization Required for [tgroup. % =================================== % % The \xbegin command defines the TeX formatting to be inserted at the % begining of a group of rules. Its arguments are: % #1 - TeX command to be used for the \trule command % #2 - the number of KB-conditions in each rule % #3 - the number of columns in the table (#2 + 1) % #4 - the width of each column % #5 - the title for the group of rules % In this tabular form, we create a table using the LaTeX tabular % environment. Note that a fancier tabular style, such as one that % handle page breaks gracefully could be used instead. % % The \sep command defines the TeX formatting to be inserted to add % some extra separation between subgroups of a group of rules. In % this tabular form, it inserts a horizontal line in the table. % % The \xend command defines the TeX formatting to be inserted at the % end of a group of rules. In this tabular form, it closes the LaTeX % tabular environment. % % See the "The [tgroup command" subsection of "The Implementation" section % in the paper for more details. % \gdef\xbegin#1#2#3#4#5{ \gdef\trule{\csname #1\endcsname} \gdef\numcols{#3} \par\begin{tabular}{*{#3}{|p{#4\textwidth}}|} \hline \multicolumn{#3}{|c|}{\rule{0pt}{2.8ex}\large\bf #5 Rules}\\ \hline \multicolumn{#2}{|c|}{\rule{0pt}{2.8ex}\large Conditions} & \large Conclu\-sion \\ \hline\hline } \gdef\xsep{\hline} \gdef\xend{\hline\end{tabular}} % % Customization Required for [trule. % ================================== % % The \xpre command defines the TeX formatting to be inserted for an % empty KB-condition. In this tabular form, it inserts a column % separator (&). % % The \xif command defines the TeX formatting to be inserted for the % first non-empty KB-condition. It takes one argument: % #1 - The first non-empty KB-condition % In this tabular form, it inserts the TeX codes to be "very relaxed" % about formatting (particularly in narrow columns) and the % KB-condition. % % The \xand command defines the TeX formatting to be inserted for the % rest of the KB-conditions. It takes one argument: % #1 - The KB-condition % In this tabular form, it inserts the TeX codes to be "very relaxed" % about formatting (particularly in narrow columns) and the % KB-condition, if it is non-empty. % % The \xthen command defines the TeX formatting to be inserted for the % KB-consequence. It takes one argument: % #1 - The KB-consequence % In this tabular form, it inserts the column separator (&), the TeX codes % to be "very relaxed" about formatting (particularly in narrow columns) % the KB-consequence and the row terminator (\\). % % See the "The [trule command" subsection of "The Implementation" section % in the paper for more details. % \gdef\xpre{&} \gdef\xif#1{\RS\xrel #1} \gdef\xand#1{& \RS\ifx#1\empty\else\xrel #1\fi} \gdef\xthen#1{& \PBS\RS\xrel #1 \\} % % Customization Required for [ttext and [trem. % ============================================ % % The \xtext command defines the TeX formatting to be inserted for % arbitrary explanatory text. It takes one argument: % #1 - The explantory text % In this tabular form, it prints the text---in italics---spanned across % all the columns. % % The \xrem command defines the TeX formatting to be inserted for % extra explanatory text into the tabular form. It takes one argument: % #1 - The extra explantory text % In this tabular form, it prints the text like \ttext, except the text % is printed in SmallCaps. % \gdef\xtext#1{\multicolumn{\numcols}{|p{.9\textwidth}|}{\em #1}\\ \hline} \gdef\xrem#1{\xtext{\sc #1}} % % Support commands. % ================= % % The \RS command is the TeX code to be "very relaxed" about formatting; % see The LaTeX Companion, page 132 (for \hspace{0pt}) % % The \PBS command is an abbreviation for the \PreserveBackslash command % which allows us to bend the rules about where the LaTeX tabular row % terminator (\\) must be placed (ie. in a command which does not contain % the whole row); see The LaTeX Companion, page 108 % \gdef\RS{\raggedright\sloppy\hspace{0pt}} \gdef\PreserveBackslash#1{\let\temp=\\#1\let\\=\temp} \let\PBS=\PreserveBackslash