diff options
author | Karl Berry <karl@freefriends.org> | 2015-07-17 22:38:26 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-07-17 22:38:26 +0000 |
commit | f96a05fb5d050b38a4808a0f260c0ecee26b7fde (patch) | |
tree | d6f437ec53490c134127548c2c97ddd78360326f | |
parent | e49b1ec410f73a528d88a0a9d082b4eb259ab051 (diff) |
conteq (17jul15)
git-svn-id: svn://tug.org/texlive/trunk@37868 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/conteq/README | 28 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/conteq/README.txt | 11 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/conteq/conteq.pdf | bin | 304493 -> 394599 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/conteq/conteq.dtx | 265 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/conteq/conteq.ins | 13 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/conteq/conteq.sty | 242 |
6 files changed, 271 insertions, 288 deletions
diff --git a/Master/texmf-dist/doc/latex/conteq/README b/Master/texmf-dist/doc/latex/conteq/README deleted file mode 100644 index 2fc87fe3fbd..00000000000 --- a/Master/texmf-dist/doc/latex/conteq/README +++ /dev/null @@ -1,28 +0,0 @@ ----------------------------------------------------------------- -conteq --- continued equalities -E-mail: mail@joachim-breitner.de -Released under the LaTeX Project Public License v1.3c or later -See http://www.latex-project.org/lppl.txt ----------------------------------------------------------------- - -This package allows you to write an continued equality such as - - \begin{conteq} - e^{\pi\cdot i} \\ - = -1 & Euler's formula \\ - < 0 & this is an inequality \\ - < \sqrt 3 \\ - = \int e^{-x^2} dx & this is due to Gauss. - \end{conteq} - -in a declarative manner and easily switch between various layouts afterwards. - - - - - - - - - - diff --git a/Master/texmf-dist/doc/latex/conteq/README.txt b/Master/texmf-dist/doc/latex/conteq/README.txt index 2fc87fe3fbd..76e477ea1bb 100644 --- a/Master/texmf-dist/doc/latex/conteq/README.txt +++ b/Master/texmf-dist/doc/latex/conteq/README.txt @@ -1,6 +1,8 @@ ---------------------------------------------------------------- conteq --- continued equalities E-mail: mail@joachim-breitner.de +Source repository: http://git.nomeata.de/?p=conteq.git +Source repository mirror: https://github.com/nomeata/conteq Released under the LaTeX Project Public License v1.3c or later See http://www.latex-project.org/lppl.txt ---------------------------------------------------------------- @@ -17,12 +19,3 @@ This package allows you to write an continued equality such as in a declarative manner and easily switch between various layouts afterwards. - - - - - - - - - diff --git a/Master/texmf-dist/doc/latex/conteq/conteq.pdf b/Master/texmf-dist/doc/latex/conteq/conteq.pdf Binary files differindex a9541929615..2f84eaefee0 100644 --- a/Master/texmf-dist/doc/latex/conteq/conteq.pdf +++ b/Master/texmf-dist/doc/latex/conteq/conteq.pdf diff --git a/Master/texmf-dist/source/latex/conteq/conteq.dtx b/Master/texmf-dist/source/latex/conteq/conteq.dtx index b36696ae23b..07ce18b5a4f 100644 --- a/Master/texmf-dist/source/latex/conteq/conteq.dtx +++ b/Master/texmf-dist/source/latex/conteq/conteq.dtx @@ -7,6 +7,8 @@ ---------------------------------------------------------------- conteq --- continued equalities E-mail: mail@joachim-breitner.de +Source repository: http://git.nomeata.de/?p=conteq.git +Source repository mirror: https://github.com/nomeata/conteq Released under the LaTeX Project Public License v1.3c or later See http://www.latex-project.org/lppl.txt ---------------------------------------------------------------- @@ -45,7 +47,7 @@ See http://www.latex-project.org/lppl.txt \endpreamble \postamble -Copyright (C) 2013 by Joachim Breitner <mail@joachim-breitner.de> +Copyright (C) 2013,2015 by Joachim Breitner <mail@joachim-breitner.de> This work may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either @@ -85,11 +87,11 @@ and the derived files conteq.ins, \fi %</internal> %<package>\NeedsTeXFormat{LaTeX2e} -%<package>\RequirePackage{expl3} +%<package>\RequirePackage{expl3}[2012/07/02] %<package>\ProvidesExplPackage %<package> {conteq} % Package name -%<package> {2013/05/23} % Release date -%<package> {0.1} % Release version +%<package> {2015/07/17} % Release date +%<package> {0.1.1} % Release version %<package> {Various layouts for continued equalities} % Description % %<*driver> @@ -109,7 +111,7 @@ and the derived files conteq.ins, % % \GetFileInfo{\jobname.sty} % -% \CheckSum{166} +% \CheckSum{175} % % %\title{^^A @@ -123,6 +125,7 @@ and the derived files conteq.ins, % %\maketitle % +%\changes{0.1.1}{2015/07/17}{Stop using deprecated expl3 macros} %\changes{0.1}{2013/05/23}{Converted to DTX file} % % @@ -156,19 +159,19 @@ and the derived files conteq.ins, % = \int e^{-x^2} dx & this is due to Gauss. % \end{conteq} % -% The expressions are typeset in math mode, while the explanation is assumed to be regular text. The curly braces around the explanations come from the default |\ConteqExplanationLayout|. - +% The expressions are typeset in math mode, while the explanation is assumed to be regular text. The curly braces around the explanations come from the default |\ConteqExplStyle|. +% % There are other layouts available, which you select with an optional parameter to |\begin{conteq}|, e.g. % \begin{verbatim} % \begin{conteq}[explline] % [..] % \end{conteq} % \end{verbatim} - +% % The layouts defined by |conteq| are: - +% % \paragraph{plain} The default layout, shown above. - +% % \paragraph{explline} A layout that puts the explanations below the right-hand side of the equalty it is explaining. To be used when the explanations and righ-hand sides are long. % \begin{conteq}[explline] % e^{\pi\cdot i} \\ @@ -178,7 +181,7 @@ and the derived files conteq.ins, % = \int e^{-x^2} dx & this is due to Gauss. % \end{conteq} - +% % \paragraph{headline} Like plain, but the first expression is also vertically aligned with the right-hand sides. % \begin{conteq}[headline] % e^{\pi\cdot i} \\ @@ -187,7 +190,7 @@ and the derived files conteq.ins, % < \sqrt 3 \\ % = \int e^{-x^2} dx & this is due to Gauss. % \end{conteq} - +% % \paragraph{onecolumn} A combination of \textbf{explline} and \textbf{headline} that puts everything in one column, for maximum space efficiency. % \begin{conteq}[onecolumn] % e^{\pi\cdot i} \\ @@ -196,7 +199,7 @@ and the derived files conteq.ins, % < \sqrt 3 \\ % = \int e^{-x^2} dx & this is due to Gauss. % \end{conteq} - +% % \paragraph{oneline} A layout, more for demonstrational purposes, that ignores the explanations and puts everything in one line. % \begin{conteq}[oneline] % e^{\pi\cdot i} \\ @@ -205,9 +208,9 @@ and the derived files conteq.ins, % < \sqrt 3 \\ % = \int e^{-x^2} dx & this is due to Gauss. % \end{conteq} - +% % \DescribeMacro{\ConteqSetDefaultLayout} You can change the default layout using |\ConteqSetDefaultLayout|\marg{layout} - +% % \section{Defining layouts} % % \DescribeMacro{\ConteqDefineLayout} @@ -296,6 +299,8 @@ and the derived files conteq.ins, % % One feature that I am considering is an auto-selection of layouts, so when you specify |\begin{conteq}[plain,explline,onecolumn]...\end{conteq}|, it will analyze the table and select, from your list of layouts, the first one that is ``ok'', where ``ok'' would be some layout-specific heuristic taking the size of the expressions and explanations as well as the current |\linewidth| into account. If you think that this would be useful to you, please let me know. % +% You can follow the package's development at \url{http://git.nomeata.de/?p=conteq.git} or the mirror at \url{https://github.com/nomeata/conteq}. +% % \iffalse %</layouts> % \fi @@ -305,7 +310,7 @@ and the derived files conteq.ins, % \PrintIndex %} % - +% % % \section{Implementation} % @@ -319,39 +324,39 @@ and the derived files conteq.ins, \RequirePackage{amsmath} \RequirePackage{environ} % \end{macrocode} - +% % \subsection{Defining Messages} % % \begin{macrocode} \msg_new:nnn - {conteq} - {empty} - { \msg_warning_text:n{conteq}:~Empty~conteq~environment~\msg_line_context: } + { conteq } + { empty } + { Empty~conteq~environment~\msg_line_context: } \msg_new:nnn - {conteq} - {ignoreddata} - { \msg_warning_text:n{conteq}:~Ignored~text~\msg_line_context: } + { conteq } + { ignoreddata } + { Ignored~text~\msg_line_context: } \msg_new:nnn - {conteq} - {undefinedlayout} - { \msg_critical_text:n{conteq}:~Undefined~layout~``#1''~\msg_line_context: } + { conteq } + { undefined layout } + { Undefined~layout~``#1''~\msg_line_context: } % \end{macrocode} % \subsection{Declaring local variables} % % \begin{macrocode} -\tl_new:N \l_conteq_default_layout_tl -\tl_new:N \l_conteq_layout_tl -\tl_new:N \l_conteq_body_tl -\tl_new:N \l_conteq_lines_seq -\tl_new:N \l_conteq_cells_seq -\tl_new:N \l_conteq_head_tl -\tl_new:N \l_conteq_lastline_tl -\tl_new:N \l_conteq_rhs_tl -\tl_new:N \l_conteq_expl_tl -\tl_new:N \l_conteq_result_tl +\tl_new:N \l__conteq_default_layout_tl +\tl_new:N \l__conteq_layout_tl +\tl_new:N \l__conteq_body_tl +\tl_new:N \l__conteq_lines_seq +\tl_new:N \l__conteq_cells_seq +\tl_new:N \l__conteq_head_tl +\tl_new:N \l__conteq_lastline_tl +\tl_new:N \l__conteq_rhs_tl +\tl_new:N \l__conteq_expl_tl +\tl_new:N \l__conteq_result_tl % \end{macrocode} % \subsection{Layouts} @@ -359,75 +364,87 @@ and the derived files conteq.ins, % \begin{macro}{\ConteqSetDefaultLayout} % The code to set the default layout. % \begin{macrocode} -\cs_new_protected:Nn \conteq_set_default_layout:n { - \tl_set:Nn \l_conteq_default_layout_tl {#1} -} -\cs_new_eq:NN \ConteqSetDefaultLayout \conteq_set_default_layout:n +\cs_new_protected:Nn \__conteq_set_default_layout:n + { + \tl_set:Nn \l__conteq_default_layout_tl {#1} + } +\cs_new_eq:NN \ConteqSetDefaultLayout \__conteq_set_default_layout:n % \end{macrocode} % \end{macro} % % \begin{macro}{\ConteqDefineLayout} % The code to define new layouts. % \begin{macrocode} -\cs_new_protected:Nn \conteq_define_layout:nnnnnnn { - \cs_new_protected:cn {conteq_#1_begin:} { #2 } - \cs_new_protected:cn {conteq_#1_lhs:n} { #3 } - \cs_new_protected:cn {conteq_#1_rhs_only:n} { #4 } - \cs_new_protected:cn {conteq_#1_rhs_expl:nn} { #5 } - \cs_new_protected:cn {conteq_#1_nl:} { #6 } - \cs_new_protected:cn {conteq_#1_end:} { #7 } -} -\cs_new_eq:NN \ConteqDefineLayout \conteq_define_layout:nnnnnnn +\tl_const:Nn \c__conteq_prefix_tl { __conteq_layouts } + +\cs_new_protected:Nn \__conteq_define_layout:nnnnnnn + { + \cs_new_protected:cn { \c__conteq_prefix_tl _ #1 _begin: } { #2 } + \cs_new_protected:cn { \c__conteq_prefix_tl _ #1_lhs:n } { #3 } + \cs_new_protected:cn { \c__conteq_prefix_tl _ #1_rhs_only:n } { #4 } + \cs_new_protected:cn { \c__conteq_prefix_tl _ #1_rhs_expl:nn } { #5 } + \cs_new_protected:cn { \c__conteq_prefix_tl _ #1_nl: } { #6 } + \cs_new_protected:cn { \c__conteq_prefix_tl _ #1_end: } { #7 } + } +\cs_new_eq:NN \ConteqDefineLayout \__conteq_define_layout:nnnnnnn % \end{macrocode} % \end{macro} % % \subsection{Expansion utility function} % -% \begin{macro}{\conteq_args_once:Nn, \conteq_args_once:NV, \conteq_args_once:Nnn, \conteq_args_once:NVV} +% \begin{macro}{\__conteq_args_once:Nn, \__conteq_args_once:NV, \__conteq_args_once:Nnn, \__conteq_args_once:NVV} % For ease of debugging(?) we construct a token list that contains exactly the tokens that a programmer would enter to create the layout manually. For that we need some fine-grained control over expansion. % % \begin{macrocode} -\cs_new:Npn \conteq_args_once:Nn #1#2 { - \exp_not:o {#1 {#2}} -} -\cs_generate_variant:Nn \conteq_args_once:Nn {NV} +\cs_new:Npn \__conteq_args_once:Nn #1#2 + { + \exp_not:o { #1 {#2} } + } +\cs_generate_variant:Nn \__conteq_args_once:Nn { NV } -\cs_new:Npn \conteq_args_once:Nnn #1#2#3 { - \exp_not:o {#1 {#2}{#3}} -} -\cs_generate_variant:Nn \conteq_args_once:Nnn {NVV} +\cs_new:Npn \__conteq_args_once:Nnn #1#2#3 + { + \exp_not:o { #1 { #2 }{ #3 } } + } +\cs_generate_variant:Nn \__conteq_args_once:Nnn { NVV } % \end{macrocode} % \end{macro} % % \subsection{Main code} % -% \begin{macro}{\conteq_print_line:nn} +% \begin{macro}{\__conteq_print_line:nn} % This macro splits and prints one line of the table. The second argument is either |\\| or, for the last line of the table, empty. % \begin{macrocode} -\cs_new_protected:Npn \conteq_print_line:Nnn #1#2#3 { - \seq_set_split:Nnn \l_conteq_cells_seq { & } {#2} - \seq_pop_left:NN \l_conteq_cells_seq \l_conteq_rhs_tl - \tl_clear:N \l_conteq_expl_tl - \seq_if_empty:NF \l_conteq_cells_seq { - \seq_pop_left:NN \l_conteq_cells_seq \l_conteq_expl_tl - } - \tl_if_blank:VTF \l_conteq_expl_tl { - \tl_put_right:Nx #1 { - \conteq_args_once:NV \conteq_rhs_only:n \l_conteq_rhs_tl - } - }{ - \tl_set:Nx \l_tmpa_tl {\exp_not:N \text {\exp_not:N \ConteqExplStyle {\exp_not:V \l_conteq_expl_tl}}} - \tl_put_right:Nx #1 { - \conteq_args_once:NVV \conteq_rhs_expl:nn \l_conteq_rhs_tl \l_tmpa_tl - } - } - \seq_if_empty:NF \l_conteq_cells_seq { - \msg_warning:nn{conteq}{ignoreddata} +\cs_new_protected:Npn \__conteq_print_line:Nnn #1#2#3 + { + \seq_set_split:Nnn \l__conteq_cells_seq { & } { #2 } + \seq_pop_left:NN \l__conteq_cells_seq \l__conteq_rhs_tl + \tl_clear:N \l__conteq_expl_tl + \seq_if_empty:NF \l__conteq_cells_seq + { + \seq_pop_left:NN \l__conteq_cells_seq \l__conteq_expl_tl + } + \tl_if_blank:VTF \l__conteq_expl_tl + { + \tl_put_right:Nx #1 + { + \__conteq_args_once:NV \__conteq_rhs_only:n \l__conteq_rhs_tl + } + } + { + \tl_set:Nx \l_tmpa_tl { \exp_not:N \text { \exp_not:N \ConteqExplStyle { \exp_not:V \l__conteq_expl_tl } } } + \tl_put_right:Nx #1 + { + \__conteq_args_once:NVV \__conteq_rhs_expl:nn \l__conteq_rhs_tl \l_tmpa_tl + } + } + \seq_if_empty:NF \l__conteq_cells_seq + { + \msg_warning:nn{conteq}{ignoreddata} + } + \tl_put_right:Nn #1 {#3} } - \tl_put_right:Nn #1 {#3} -} -\cs_generate_variant:Nn \conteq_print_line:Nnn {Nno} -\cs_generate_variant:Nn \conteq_print_line:Nnn {NVn} +\cs_generate_variant:Nn \__conteq_print_line:Nnn { Nno, NVn } % \end{macrocode} % \end{macro} @@ -436,71 +453,81 @@ and the derived files conteq.ins, % % The main environment of the package. % \begin{macrocode} -\NewEnviron{conteq}[1][\l_conteq_default_layout_tl]{ - \tl_set:NV \l_conteq_body_tl \BODY +\NewEnviron{ conteq }[1][ \l__conteq_default_layout_tl ]{ + \tl_set:NV \l__conteq_body_tl \BODY - \tl_if_blank:oT \l_conteq_body_tl{ + \tl_if_blank:oT \l__conteq_body_tl + { \msg_warning:nn{conteq}{empty} - } + } % \end{macrocode} % Figure out the layout to use\ldots % \begin{macrocode} - \tl_set:Nn \l_conteq_layout_tl {#1} + \tl_set:Nn \l__conteq_layout_tl { #1 } % \end{macrocode} % and set the various functions accordingly, if the layout exists. % \begin{macrocode} - \cs_if_exist:cTF {conteq_ \l_conteq_layout_tl _ begin:}{ - \clist_map_inline:nn{begin:, lhs:n,rhs_only:n, rhs_expl:nn, nl:, end:}{ - \cs_set_eq:cc {conteq_##1}{conteq_\l_conteq_layout_tl _##1} + \cs_if_exist:cTF { \c__conteq_prefix_tl _ \l__conteq_layout_tl _ begin: } + { + \clist_map_inline:nn{ begin:, lhs:n,rhs_only:n, rhs_expl:nn, nl:, end: } + { + \cs_set_eq:cc { __conteq_ ##1 }{ \c__conteq_prefix_tl _ \l__conteq_layout_tl _ ##1 } + } + }{ + \msg_critical:nnx{conteq}{undefined layout}{\l__conteq_layout_tl} } - }{ - \msg_critical:nnx{conteq}{undefined layout}{\l_conteq_layout_tl} - } % \end{macrocode} % Split the body into individual lines. % \begin{macrocode} - \seq_set_split:NnV \l_conteq_lines_seq { \\ } \l_conteq_body_tl + \seq_set_split:NnV \l__conteq_lines_seq { \\ } \l__conteq_body_tl - \tl_clear:N \l_conteq_result_tl + \tl_clear:N \l__conteq_result_tl % \end{macrocode} % If there is only one line, simply print it. % \begin{macrocode} - \int_case:nnn {\seq_count:N \l_conteq_lines_seq} - { - {1} { - \tl_put_right:NV \l_conteq_result_tl \conteq_begin: - \tl_put_right:NV \l_conteq_result_tl \l_conteq_body_tl - \tl_put_right:NV \l_conteq_result_tl \conteq_end: + \int_case:nnF { \seq_count:N \l__conteq_lines_seq } + { + {1} + { + \tl_put_right:Nx \l__conteq_result_tl { \exp_not:o \__conteq_begin: } + \tl_put_right:NV \l__conteq_result_tl \l__conteq_body_tl + \tl_put_right:Nx \l__conteq_result_tl { \exp_not:o \__conteq_end: } + } } - }{ + { % \end{macrocode} -% Otherwise extract the head and the last line, and print each line using |\conteq_print_line:nn| +% Otherwise extract the head and the last line, and print each line using |\__conteq_print_line:nn| % \begin{macrocode} - \seq_pop_left:NN \l_conteq_lines_seq \l_conteq_head_tl - \seq_pop_right:NN \l_conteq_lines_seq \l_conteq_lastline_tl - - \tl_put_right:NV \l_conteq_result_tl \conteq_begin: - \tl_put_right:Nx \l_conteq_result_tl { - \conteq_args_once:NV \conteq_lhs:n \l_conteq_head_tl - } - \seq_map_inline:Nn \l_conteq_lines_seq { - \conteq_print_line:Nno \l_conteq_result_tl {##1} {\conteq_nl:} + \seq_pop_left:NN \l__conteq_lines_seq \l__conteq_head_tl + \seq_pop_right:NN \l__conteq_lines_seq \l__conteq_lastline_tl + + \tl_put_right:Nx \l__conteq_result_tl { \exp_not:o \__conteq_begin: } + \tl_put_right:Nx \l__conteq_result_tl + { + \__conteq_args_once:NV \__conteq_lhs:n \l__conteq_head_tl + } + \seq_map_inline:Nn \l__conteq_lines_seq + { + \__conteq_print_line:Nno \l__conteq_result_tl { ##1 } { \__conteq_nl: } + } + \__conteq_print_line:NVn \l__conteq_result_tl \l__conteq_lastline_tl {} + \tl_put_right:Nx \l__conteq_result_tl { \exp_not:o \__conteq_end: } } - \conteq_print_line:NVn \l_conteq_result_tl \l_conteq_lastline_tl {} - \tl_put_right:No \l_conteq_result_tl \conteq_end: + % Use this for debugging + %\tl_show:N \l__conteq_result_tl + \tl_use:N \l__conteq_result_tl } - % Use this for debugging - %\tl_show:N \l_conteq_result_tl - \tl_use:N \l_conteq_result_tl -} -\endinput % \end{macrocode} %\end{environment} +% +% \begin{macrocode} +\endinput +% \end{macrocode} % % \iffalse diff --git a/Master/texmf-dist/source/latex/conteq/conteq.ins b/Master/texmf-dist/source/latex/conteq/conteq.ins index 0fe38724fb3..fcc53d13ed9 100644 --- a/Master/texmf-dist/source/latex/conteq/conteq.ins +++ b/Master/texmf-dist/source/latex/conteq/conteq.ins @@ -26,7 +26,7 @@ See http://www.latex-project.org/lppl.txt \endpreamble \postamble -Copyright (C) 2013 by Joachim Breitner <mail@joachim-breitner.de> +Copyright (C) 2013,2015 by Joachim Breitner <mail@joachim-breitner.de> This work may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either @@ -51,17 +51,8 @@ and the derived files conteq.ins, } \endbatchfile - - - - - - - - - %% -%% Copyright (C) 2013 by Joachim Breitner <mail@joachim-breitner.de> +%% Copyright (C) 2013,2015 by Joachim Breitner <mail@joachim-breitner.de> %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License (LPPL), either diff --git a/Master/texmf-dist/tex/latex/conteq/conteq.sty b/Master/texmf-dist/tex/latex/conteq/conteq.sty index 68dbb6e6ce9..1b7f88a6de5 100644 --- a/Master/texmf-dist/tex/latex/conteq/conteq.sty +++ b/Master/texmf-dist/tex/latex/conteq/conteq.sty @@ -14,153 +14,154 @@ %% ---------------------------------------------------------------- %% \NeedsTeXFormat{LaTeX2e} -\RequirePackage{expl3} +\RequirePackage{expl3}[2012/07/02] \ProvidesExplPackage {conteq} % Package name - {2013/05/23} % Release date - {0.1} % Release version + {2015/07/17} % Release date + {0.1.1} % Release version {Various layouts for continued equalities} % Description - - - - - - - - - \RequirePackage{amsmath} \RequirePackage{environ} - \msg_new:nnn - {conteq} - {empty} - { \msg_warning_text:n{conteq}:~Empty~conteq~environment~\msg_line_context: } + { conteq } + { empty } + { Empty~conteq~environment~\msg_line_context: } \msg_new:nnn - {conteq} - {ignoreddata} - { \msg_warning_text:n{conteq}:~Ignored~text~\msg_line_context: } + { conteq } + { ignoreddata } + { Ignored~text~\msg_line_context: } \msg_new:nnn - {conteq} - {undefinedlayout} - { \msg_critical_text:n{conteq}:~Undefined~layout~``#1''~\msg_line_context: } - -\tl_new:N \l_conteq_default_layout_tl -\tl_new:N \l_conteq_layout_tl -\tl_new:N \l_conteq_body_tl -\tl_new:N \l_conteq_lines_seq -\tl_new:N \l_conteq_cells_seq -\tl_new:N \l_conteq_head_tl -\tl_new:N \l_conteq_lastline_tl -\tl_new:N \l_conteq_rhs_tl -\tl_new:N \l_conteq_expl_tl -\tl_new:N \l_conteq_result_tl - -\cs_new_protected:Nn \conteq_set_default_layout:n { - \tl_set:Nn \l_conteq_default_layout_tl {#1} -} -\cs_new_eq:NN \ConteqSetDefaultLayout \conteq_set_default_layout:n -\cs_new_protected:Nn \conteq_define_layout:nnnnnnn { - \cs_new_protected:cn {conteq_#1_begin:} { #2 } - \cs_new_protected:cn {conteq_#1_lhs:n} { #3 } - \cs_new_protected:cn {conteq_#1_rhs_only:n} { #4 } - \cs_new_protected:cn {conteq_#1_rhs_expl:nn} { #5 } - \cs_new_protected:cn {conteq_#1_nl:} { #6 } - \cs_new_protected:cn {conteq_#1_end:} { #7 } -} -\cs_new_eq:NN \ConteqDefineLayout \conteq_define_layout:nnnnnnn -\cs_new:Npn \conteq_args_once:Nn #1#2 { - \exp_not:o {#1 {#2}} -} -\cs_generate_variant:Nn \conteq_args_once:Nn {NV} + { conteq } + { undefined layout } + { Undefined~layout~``#1''~\msg_line_context: } + +\tl_new:N \l__conteq_default_layout_tl +\tl_new:N \l__conteq_layout_tl +\tl_new:N \l__conteq_body_tl +\tl_new:N \l__conteq_lines_seq +\tl_new:N \l__conteq_cells_seq +\tl_new:N \l__conteq_head_tl +\tl_new:N \l__conteq_lastline_tl +\tl_new:N \l__conteq_rhs_tl +\tl_new:N \l__conteq_expl_tl +\tl_new:N \l__conteq_result_tl + +\cs_new_protected:Nn \__conteq_set_default_layout:n + { + \tl_set:Nn \l__conteq_default_layout_tl {#1} + } +\cs_new_eq:NN \ConteqSetDefaultLayout \__conteq_set_default_layout:n +\tl_const:Nn \c__conteq_prefix_tl { __conteq_layouts } -\cs_new:Npn \conteq_args_once:Nnn #1#2#3 { - \exp_not:o {#1 {#2}{#3}} -} -\cs_generate_variant:Nn \conteq_args_once:Nnn {NVV} -\cs_new_protected:Npn \conteq_print_line:Nnn #1#2#3 { - \seq_set_split:Nnn \l_conteq_cells_seq { & } {#2} - \seq_pop_left:NN \l_conteq_cells_seq \l_conteq_rhs_tl - \tl_clear:N \l_conteq_expl_tl - \seq_if_empty:NF \l_conteq_cells_seq { - \seq_pop_left:NN \l_conteq_cells_seq \l_conteq_expl_tl +\cs_new_protected:Nn \__conteq_define_layout:nnnnnnn + { + \cs_new_protected:cn { \c__conteq_prefix_tl _ #1 _begin: } { #2 } + \cs_new_protected:cn { \c__conteq_prefix_tl _ #1_lhs:n } { #3 } + \cs_new_protected:cn { \c__conteq_prefix_tl _ #1_rhs_only:n } { #4 } + \cs_new_protected:cn { \c__conteq_prefix_tl _ #1_rhs_expl:nn } { #5 } + \cs_new_protected:cn { \c__conteq_prefix_tl _ #1_nl: } { #6 } + \cs_new_protected:cn { \c__conteq_prefix_tl _ #1_end: } { #7 } } - \tl_if_blank:VTF \l_conteq_expl_tl { - \tl_put_right:Nx #1 { - \conteq_args_once:NV \conteq_rhs_only:n \l_conteq_rhs_tl - } - }{ - \tl_set:Nx \l_tmpa_tl {\exp_not:N \text {\exp_not:N \ConteqExplStyle {\exp_not:V \l_conteq_expl_tl}}} - \tl_put_right:Nx #1 { - \conteq_args_once:NVV \conteq_rhs_expl:nn \l_conteq_rhs_tl \l_tmpa_tl - } +\cs_new_eq:NN \ConteqDefineLayout \__conteq_define_layout:nnnnnnn +\cs_new:Npn \__conteq_args_once:Nn #1#2 + { + \exp_not:o { #1 {#2} } + } +\cs_generate_variant:Nn \__conteq_args_once:Nn { NV } + +\cs_new:Npn \__conteq_args_once:Nnn #1#2#3 + { + \exp_not:o { #1 { #2 }{ #3 } } } - \seq_if_empty:NF \l_conteq_cells_seq { - \msg_warning:nn{conteq}{ignoreddata} +\cs_generate_variant:Nn \__conteq_args_once:Nnn { NVV } +\cs_new_protected:Npn \__conteq_print_line:Nnn #1#2#3 + { + \seq_set_split:Nnn \l__conteq_cells_seq { & } { #2 } + \seq_pop_left:NN \l__conteq_cells_seq \l__conteq_rhs_tl + \tl_clear:N \l__conteq_expl_tl + \seq_if_empty:NF \l__conteq_cells_seq + { +\seq_pop_left:NN \l__conteq_cells_seq \l__conteq_expl_tl + } + \tl_if_blank:VTF \l__conteq_expl_tl + { +\tl_put_right:Nx #1 + { + \__conteq_args_once:NV \__conteq_rhs_only:n \l__conteq_rhs_tl } - \tl_put_right:Nn #1 {#3} + } + { +\tl_set:Nx \l_tmpa_tl { \exp_not:N \text { \exp_not:N \ConteqExplStyle { \exp_not:V \l__conteq_expl_tl } } } +\tl_put_right:Nx #1 + { + \__conteq_args_once:NVV \__conteq_rhs_expl:nn \l__conteq_rhs_tl \l_tmpa_tl + } + } + \seq_if_empty:NF \l__conteq_cells_seq +{ + \msg_warning:nn{conteq}{ignoreddata} } -\cs_generate_variant:Nn \conteq_print_line:Nnn {Nno} -\cs_generate_variant:Nn \conteq_print_line:Nnn {NVn} + \tl_put_right:Nn #1 {#3} + } +\cs_generate_variant:Nn \__conteq_print_line:Nnn { Nno, NVn } -\NewEnviron{conteq}[1][\l_conteq_default_layout_tl]{ - \tl_set:NV \l_conteq_body_tl \BODY +\NewEnviron{ conteq }[1][ \l__conteq_default_layout_tl ]{ + \tl_set:NV \l__conteq_body_tl \BODY - \tl_if_blank:oT \l_conteq_body_tl{ + \tl_if_blank:oT \l__conteq_body_tl + { \msg_warning:nn{conteq}{empty} - } - - \tl_set:Nn \l_conteq_layout_tl {#1} - \cs_if_exist:cTF {conteq_ \l_conteq_layout_tl _ begin:}{ - \clist_map_inline:nn{begin:, lhs:n,rhs_only:n, rhs_expl:nn, nl:, end:}{ - \cs_set_eq:cc {conteq_##1}{conteq_\l_conteq_layout_tl _##1} } - }{ - \msg_critical:nnx{conteq}{undefined layout}{\l_conteq_layout_tl} - } - - \seq_set_split:NnV \l_conteq_lines_seq { \\ } \l_conteq_body_tl - \tl_clear:N \l_conteq_result_tl + \tl_set:Nn \l__conteq_layout_tl { #1 } + \cs_if_exist:cTF { \c__conteq_prefix_tl _ \l__conteq_layout_tl _ begin: } + { + \clist_map_inline:nn{ begin:, lhs:n,rhs_only:n, rhs_expl:nn, nl:, end: } + { + \cs_set_eq:cc { __conteq_ ##1 }{ \c__conteq_prefix_tl _ \l__conteq_layout_tl _ ##1 } + } + }{ + \msg_critical:nnx{conteq}{undefined layout}{\l__conteq_layout_tl} + } + \seq_set_split:NnV \l__conteq_lines_seq { \\ } \l__conteq_body_tl - \int_case:nnn {\seq_count:N \l_conteq_lines_seq} - { - {1} { - \tl_put_right:NV \l_conteq_result_tl \conteq_begin: - \tl_put_right:NV \l_conteq_result_tl \l_conteq_body_tl - \tl_put_right:NV \l_conteq_result_tl \conteq_end: - } - }{ + \tl_clear:N \l__conteq_result_tl - \seq_pop_left:NN \l_conteq_lines_seq \l_conteq_head_tl - \seq_pop_right:NN \l_conteq_lines_seq \l_conteq_lastline_tl - \tl_put_right:NV \l_conteq_result_tl \conteq_begin: - \tl_put_right:Nx \l_conteq_result_tl { - \conteq_args_once:NV \conteq_lhs:n \l_conteq_head_tl + \int_case:nnF { \seq_count:N \l__conteq_lines_seq } + { + {1} + { + \tl_put_right:Nx \l__conteq_result_tl { \exp_not:o \__conteq_begin: } + \tl_put_right:NV \l__conteq_result_tl \l__conteq_body_tl + \tl_put_right:Nx \l__conteq_result_tl { \exp_not:o \__conteq_end: } + } } - \seq_map_inline:Nn \l_conteq_lines_seq { - \conteq_print_line:Nno \l_conteq_result_tl {##1} {\conteq_nl:} + { + + \seq_pop_left:NN \l__conteq_lines_seq \l__conteq_head_tl + \seq_pop_right:NN \l__conteq_lines_seq \l__conteq_lastline_tl + + \tl_put_right:Nx \l__conteq_result_tl { \exp_not:o \__conteq_begin: } + \tl_put_right:Nx \l__conteq_result_tl + { + \__conteq_args_once:NV \__conteq_lhs:n \l__conteq_head_tl + } + \seq_map_inline:Nn \l__conteq_lines_seq + { + \__conteq_print_line:Nno \l__conteq_result_tl { ##1 } { \__conteq_nl: } + } + \__conteq_print_line:NVn \l__conteq_result_tl \l__conteq_lastline_tl {} + \tl_put_right:Nx \l__conteq_result_tl { \exp_not:o \__conteq_end: } } - \conteq_print_line:NVn \l_conteq_result_tl \l_conteq_lastline_tl {} - \tl_put_right:No \l_conteq_result_tl \conteq_end: + % Use this for debugging + %\tl_show:N \l__conteq_result_tl + \tl_use:N \l__conteq_result_tl } - % Use this for debugging - %\tl_show:N \l_conteq_result_tl - \tl_use:N \l_conteq_result_tl -} - - - - - - - - \ConteqDefineLayout @@ -210,9 +211,8 @@ {\]} \newcommand{\ConteqExplStyle}[1]{\{~#1~\}} - %% -%% Copyright (C) 2013 by Joachim Breitner <mail@joachim-breitner.de> +%% Copyright (C) 2013,2015 by Joachim Breitner <mail@joachim-breitner.de> %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License (LPPL), either |