diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3experimental/xgalley/l3galley.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3experimental/xgalley/l3galley.dtx | 163 |
1 files changed, 117 insertions, 46 deletions
diff --git a/Master/texmf-dist/source/latex/l3experimental/xgalley/l3galley.dtx b/Master/texmf-dist/source/latex/l3experimental/xgalley/l3galley.dtx index dc6279914af..cb34e8a92aa 100644 --- a/Master/texmf-dist/source/latex/l3experimental/xgalley/l3galley.dtx +++ b/Master/texmf-dist/source/latex/l3experimental/xgalley/l3galley.dtx @@ -1,7 +1,7 @@ % \iffalse % %% File: l3galley.dtx Copyright (C) 1999-2001, 2004-2009 Frank Mittelbach -%% (C) 2010,2011 The LaTeX3 Project +%% (C) 2010-2012 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of the %% LaTeX Project Public License (LPPL), either version 1.3c of this @@ -36,8 +36,8 @@ %% % %<*driver|package> -\RequirePackage{l3names} -\GetIdInfo$Id: l3galley.dtx 3205 2012-01-18 22:09:05Z joseph $ +\RequirePackage{xparse} +\GetIdInfo$Id: l3galley.dtx 3253 2012-01-28 14:59:55Z joseph $ {L3 Experimental galley code} %</driver|package> %<*driver> @@ -410,6 +410,16 @@ % relational symbol. % \end{variable} % +% \begin{function}{\galley_break_line:Nn} +% \begin{syntax} +% \cs{galley_break_line:Nn} \meta{boolean} \Arg{dim expr} +% \end{syntax} +% Breaks the current line, filling the remaining space with \texttt{fil} +% glue. If the \meta{boolean} is \texttt{true} then a page break is possible +% after the broken line. Vertical space as given by the \meta{dim expr} will +% be inserted between the broken line and the next line. +% \end{function} +% % \subsection{Paragraph breaking} % % \begin{variable}{\l_galley_parbreak_badness_int} @@ -1180,7 +1190,7 @@ % token list, before setting up the value to the special value needed % in this one case. % \begin{macrocode} -\cs_new_protected_nopar:Npn \galley_display_penalty:N #1 +\cs_new_protected:Npn \galley_display_penalty:N #1 { \tl_if_empty:NF #1 { @@ -1192,7 +1202,7 @@ \int_gset:Nn \g_galley_penalty_int {#1} } } -\cs_new_protected_nopar:Npn \galley_display_vspace:N #1 +\cs_new_protected:Npn \galley_display_vspace:N #1 { \tl_if_empty:NF #1 { @@ -1471,7 +1481,7 @@ % Setting the measure is just a question of adjusting margins, either % in a relative or absolute sense. % \begin{macrocode} -\cs_new_protected_nopar:Npn \galley_margins_set_absolute:nn #1#2 +\cs_new_protected:Npn \galley_margins_set_absolute:nn #1#2 { \dim_set:Nn \l_galley_total_left_margin_dim {#1} \dim_set:Nn \l_galley_total_right_margin_dim {#2} @@ -1482,7 +1492,7 @@ - \l_galley_total_right_margin_dim } } -\cs_new_protected_nopar:Npn \galley_margins_set_relative:nn #1#2 +\cs_new_protected:Npn \galley_margins_set_relative:nn #1#2 { \dim_add:Nn \l_galley_total_left_margin_dim {#1} \dim_add:Nn \l_galley_total_right_margin_dim {#2} @@ -1511,7 +1521,7 @@ % later. So this is just a case of saving the various pieces of data % to the correct locations. % \begin{macrocode} -\cs_new_protected_nopar:Npn \galley_parshape_fixed_lines:nnn #1#2#3 +\cs_new_protected:Npn \galley_parshape_fixed_lines:nnn #1#2#3 { \bool_gset_true:N \g_galley_parshape_set_bool \bool_set_true:N \l_galley_parshape_fixed_lines_bool @@ -1520,7 +1530,7 @@ \clist_set:Nn \l_galley_parshape_right_indent_clist {#3} \bool_set_true:N \l_galley_parshape_resume_std_bool } -\cs_new_protected_nopar:Npn \galley_parshape_multi_par:nnnN #1#2#3#4 +\cs_new_protected:Npn \galley_parshape_multi_par:nnnN #1#2#3#4 { \bool_gset_true:N \g_galley_parshape_set_bool \bool_set_true:N \l_galley_parshape_multipar_bool @@ -1530,7 +1540,7 @@ \clist_set:Nn \l_galley_parshape_right_indent_clist {#3} \bool_set_eq:NN \l_galley_parshape_resume_std_bool #4 } -\cs_new_protected_nopar:Npn \galley_parshape_single_par:nnnN #1#2#3#4 +\cs_new_protected:Npn \galley_parshape_single_par:nnnN #1#2#3#4 { \bool_gset_true:N \g_galley_parshape_set_bool \bool_set_false:N \l_galley_parshape_multipar_bool @@ -1613,13 +1623,12 @@ \dim_use:N \l_galley_text_width_dim } } -\cs_new_nopar:Npn \galley_set_parshape_map:nn #1#2 +\cs_new:Npn \galley_set_parshape_map:nn #1#2 { \galley_set_parshape_map_aux:nw { } #1 , \q_mark #2 , \q_stop } \cs_generate_variant:Nn \galley_set_parshape_map:nn { oo } -\cs_new_nopar:Npn \galley_set_parshape_map_aux:nw - #1#2 , #3 \q_mark #4 , #5 \q_stop +\cs_new:Npn \galley_set_parshape_map_aux:nw #1#2 , #3 \q_mark #4 , #5 \q_stop { - \bool_if:nTF { \tl_if_empty_p:n {#3} || \tl_if_empty_p:n {#4} } + \bool_if:nTF { \tl_if_empty_p:n {#3} || \tl_if_empty_p:n {#5} } { #1 \dim_eval:n { \l_galley_total_left_margin_dim + ( #2 ) } @@ -1671,7 +1680,7 @@ \dim_use:N \l_galley_text_width_dim } } -\cs_new_nopar:Npn \galley_generate_parshape_lines_aux:n #1 +\cs_new:Npn \galley_generate_parshape_lines_aux:n #1 { \etex_parshapeindent:D #1 ~ @@ -1689,9 +1698,9 @@ % form but are stored as token lists. The \texttt{x}-type expansion % deals with this nicely. % \begin{macrocode} -\cs_new_protected_nopar:Npn \galley_set_user_penalty:n #1 +\cs_new_protected:Npn \galley_set_user_penalty:n #1 { \tl_gset:Nx \g_galley_interpar_penalty_user_tl { \int_eval:n {#1} } } -\cs_new_protected_nopar:Npn \galley_set_user_vspace:n #1 +\cs_new_protected:Npn \galley_set_user_vspace:n #1 { \tl_gset:Nx \g_galley_interpar_vspace_user_tl { \skip_eval:n {#1} } } % \end{macrocode} % \end{macro} @@ -1760,7 +1769,7 @@ % (non-zero \cs{tex_fontdimen:D} \texttt{3}), then the \cs{teX_spaceskip:D} % is set to the fixed component from the font. % \begin{macrocode} -\cs_new_protected_nopar:Npn \galley_set_interword_spacing:N #1 +\cs_new_protected:Npn \galley_set_interword_spacing:N #1 { \bool_if:NTF #1 { % TODO Hook for font changes required! @@ -1776,6 +1785,17 @@ % % \subsection{Hyphenation} % +% \begin{variable}{\l_galley_hyphen_left_int} +% Currently something of a hack: this links in with language and fonts, +% so is not so straight-forward to handle. +% \begin{macrocode} +\int_new:N \l_galley_hyphen_left_int +%<*package> +\int_set:Nn \l_galley_hyphen_left_int { \tex_lefthyphenmin:D } +%</package> +% \end{macrocode} +% \end{variable} +% % \subsection{Line breaking} % % \begin{variable} @@ -1808,6 +1828,32 @@ % \end{macrocode} % \end{variable} % +% \begin{macro}{\galley_break_line:Nn} +% Terminating a line early without a new paragraph requires a few steps. +% First, any skips are removed, then any additional space to add is +% places on the surrounding vertical list. Finally, the current line +% is ended, using a penalty to prevents an overful line ending |\\| giving +% a totally-blank one in the output. The boolean argument is used to indicate +% that a break is allowed after the blank line. +% \begin{macrocode} +\cs_new_protected:Npn \galley_break_line:Nn #1#2 + { + \mode_if_vertical:TF + { \msg_kernel_error:nn { galley } { no-line-to-end } } + { + \tex_unskip:D + \bool_if:NF #1 + { \tex_vadjust:D { \tex_penalty:D \c_ten_thousand } } + \dim_compare:nNnF {#2} = \c_zero_dim + { \tex_vadjust:D { \skip_vertical:n {#2} } } + \tex_penalty:D \c_ten_thousand + \tex_hfil:D + \tex_penalty:D -\c_ten_thousand + } + } +% \end{macrocode} +%\end{macro} +% % \subsection{Paragraph breaking} % % \begin{variable} @@ -1858,7 +1904,7 @@ % the correct form, and add a $0$ penalty at the end to nullify the effect of % repeating the last value. % \begin{macrocode} -\cs_new_protected_nopar:Npn \galley_set_display_widow_penalties:n #1 +\cs_new_protected:Npn \galley_set_display_widow_penalties:n #1 { \etex_displaywidowpenalties:D \int_eval:w \clist_length:n {#1} + \c_one \int_eval_end: @@ -1866,7 +1912,7 @@ \c_zero } \cs_generate_variant:Nn \galley_set_display_widow_penalties:n { V , v } -\cs_new_protected_nopar:Npn \galley_set_widow_penalties:n #1 +\cs_new_protected:Npn \galley_set_widow_penalties:n #1 { \etex_widowpenalties:D \int_eval:w \clist_length:n {#1} + \c_one \int_eval_end: @@ -1874,7 +1920,7 @@ \c_zero } \cs_generate_variant:Nn \galley_set_widow_penalties:n { V , v } -\cs_new_nopar:Npn \galley_set_aux:n #1 { #1 ~ } +\cs_new:Npn \galley_set_aux:n #1 { #1 ~ } % \end{macrocode} % \end{macro} % \end{macro} @@ -1893,13 +1939,13 @@ % the same, but having two takes makes some special effects easier to % carry out. % \begin{macrocode} -\cs_new_protected_nopar:Npn \galley_set_club_penalties:n #1 +\cs_new_protected:Npn \galley_set_club_penalties:n #1 { \clist_set:Nn \l_galley_club_penalties_clist {#1} \galley_calc_interline_penalties: } \cs_generate_variant:Nn \galley_set_club_penalties:n { V , v } -\cs_new_protected_nopar:Npn \galley_set_interline_penalties:n #1 +\cs_new_protected:Npn \galley_set_interline_penalties:n #1 { \clist_set:Nn \l_galley_line_penalties_clist {#1} \galley_calc_interline_penalties: @@ -1917,7 +1963,7 @@ % Setting the display club penalties means first setting the primitive, % then recalculating the interline array to allow for these new values. % \begin{macrocode} -\cs_new_protected_nopar:Npn \galley_set_display_club_penalties:n #1 +\cs_new_protected:Npn \galley_set_display_club_penalties:n #1 { \etex_clubpenalties:D \int_eval:w \clist_length:n {#1} + \c_one \int_eval_end: @@ -1943,7 +1989,7 @@ % generic build system is invoked (in case the % \cs{etex_interlinepenalties:D} has accidentally been cleared). % \begin{macrocode} -\cs_new_protected_nopar:Npn \galley_set_interline_penalty:n #1 +\cs_new_protected:Npn \galley_set_interline_penalty:n #1 { \int_compare:nNnTF { \etex_interlinepenalties:D \c_zero } = \c_zero { @@ -1951,7 +1997,7 @@ \galley_calc_interline_penalties: } { - \cs_set_nopar:Npn \galley_set_interline_penalty_aux_ii:n ##1 + \cs_set:Npn \galley_set_interline_penalty_aux_ii:n ##1 { \int_eval:w \etex_interlinepenalties:D ##1 @@ -1963,7 +2009,7 @@ { \clist_length:N \l_galley_line_penalties_clist } {#1} } } -\cs_new_protected_nopar:Npn \galley_set_interline_penalty_aux:nn #1#2 +\cs_new_protected:Npn \galley_set_interline_penalty_aux:nn #1#2 { \etex_interlinepenalties:D \etex_interlinepenalties:D \c_zero @@ -1974,9 +2020,9 @@ \galley_set_interline_penalty_aux_ii:n \int_eval:w #2 \int_eval_end: } -\cs_new_nopar:Npn \galley_set_interline_penalty_aux_i:n #1 +\cs_new:Npn \galley_set_interline_penalty_aux_i:n #1 { \etex_interlinepenalties:D \int_eval:w #1 \int_eval_end: } -\cs_new_nopar:Npn \galley_set_interline_penalty_aux_ii:n #1 { } +\cs_new:Npn \galley_set_interline_penalty_aux_ii:n #1 { } % \end{macrocode} % \end{macro} % \end{macro} @@ -2025,8 +2071,7 @@ % normal lines. At the end of the process, the standard interline % penalty is always included. % \begin{macrocode} -\cs_new_protected_nopar:Npn \galley_calc_interline_penalties_aux:nn - #1#2 +\cs_new_protected:Npn \galley_calc_interline_penalties_aux:nn #1#2 { \etex_interlinepenalties:D #1 ~ \prg_stepwise_function:nnnN \c_one \c_one {#2} @@ -2035,8 +2080,7 @@ \galley_calc_interline_penalties_aux_ii:n \etex_interlinepenalties:D \etex_interlinepenalties:D \c_zero } -\cs_new_nopar:Npn \galley_calc_interline_penalties_aux_i:n - #1 +\cs_new:Npn \galley_calc_interline_penalties_aux_i:n #1 { \int_eval:w \clist_item:Nn \l_galley_line_penalties_clist { #1 - \c_one } @@ -2045,8 +2089,7 @@ - \etex_clubpenalties:D #1 ~ \int_eval_end: } -\cs_new_nopar:Npn \galley_calc_interline_penalties_aux_ii:n - #1 +\cs_new:Npn \galley_calc_interline_penalties_aux_ii:n #1 { \int_eval:w \etex_interlinepenalties:D \etex_interlinepenalties:D \c_zero @@ -2078,15 +2121,15 @@ % Saving the array penalties varies in complexity depending on how they are % stored internally. The first two are easy: these are simply copies. % \begin{macrocode} -\cs_new_protected_nopar:Npn \galley_save_club_penalties:N #1 +\cs_new_protected:Npn \galley_save_club_penalties:N #1 { \clist_set_eq:NN #1 \l_galley_club_penalties_clist } -\cs_new_protected_nopar:Npn \galley_save_interline_penalties:N #1 +\cs_new_protected:Npn \galley_save_interline_penalties:N #1 { \clist_set_eq:NN #1 \l_galley_line_penalties_clist } % \end{macrocode} % These all require appropriate mappings, using the fact that % \cs{clist_set:Nx} will tidy up the excess comma. % \begin{macrocode} -\cs_new_protected_nopar:Npn \galley_save_display_club_penalties:N #1 +\cs_new_protected:Npn \galley_save_display_club_penalties:N #1 { \clist_set:Nx #1 { @@ -2095,9 +2138,9 @@ \galley_save_display_club_penalties:_aux:n } } -\cs_new_nopar:Npn \galley_save_display_club_penalties:_aux:n #1 +\cs_new:Npn \galley_save_display_club_penalties:_aux:n #1 { \int_use:N \etex_clubpenaltes:D \int_eval:w #1 \int_eval_end: , } -\cs_new_protected_nopar:Npn \galley_save_display_widow_penalties:N #1 +\cs_new_protected:Npn \galley_save_display_widow_penalties:N #1 { \clist_set:Nx #1 { @@ -2106,9 +2149,9 @@ \galley_save_display_widow_penalties:_aux:n } } -\cs_new_nopar:Npn \galley_save_display_widow_penalties:_aux:n #1 +\cs_new:Npn \galley_save_display_widow_penalties:_aux:n #1 { \int_use:N \etex_displaywidowpenalties:D \int_eval:w #1 \int_eval_end: , } -\cs_new_protected_nopar:Npn \galley_save_widow_penalties:N #1 +\cs_new_protected:Npn \galley_save_widow_penalties:N #1 { \clist_set:Nx #1 { @@ -2117,7 +2160,7 @@ \galley_save_widow_penalties:_aux:n } } -\cs_new_nopar:Npn \galley_save_widow_penalties:_aux:n #1 +\cs_new:Npn \galley_save_widow_penalties:_aux:n #1 { \int_use:N \etex_widowpenalties:D \int_eval:w #1 \int_eval_end: , } % \end{macrocode} % This one is not an array, but is stored in a primitive, so there is @@ -2131,6 +2174,13 @@ % \end{macro} % \end{macro} % +% \subsection{Messages} +% +% \begin{macrocode} +\msg_kernel_new:nnn { galley } { no-line-to-end } + { There's~no~line~here~to~end. } +% \end{macrocode} +% % \subsection{\LaTeXe{} functions} % % \begin{macrocode} @@ -2143,7 +2193,7 @@ % In package mode, some of \LaTeXe{}'s functions are re-implemented using % the galley system. Not all of the optional arguments currently work! % \begin{macrocode} -\cs_set_protected_nopar:Npn \nobreak +\RenewDocumentCommand \nobreak { } { \bool_gset_true:N \g_galley_no_break_next_bool } % \end{macrocode} % The \tn{noindent} primitive will causes problems, as it is used by @@ -2152,12 +2202,12 @@ % need leave vertical mode, at the moment we stick with the primitive as % well as setting the galley flag. % \begin{macrocode} -\cs_set_protected_nopar:Npn \noindent +\RenewDocumentCommand \noindent { } { \tex_noindent:D \bool_gset_false:N \g_galley_omit_next_indent_bool } -\cs_set_protected_nopar:Npn \vspace #1 +\RenewDocumentCommand \vspace { m } { \@ifstar { \galley_set_user_vspace:n {#1} } @@ -2168,6 +2218,19 @@ % \end{macro} % \end{macro} % +% \begin{macro}{\\} +% \begin{macro}{\newline} +% These functions pass their arguments straight through to the internal +% implementation (which is currently just the \LaTeXe{} one recoded). +% \begin{macrocode} +\RenewDocumentCommand \\ { s O { 0 pt } } + { \galley_break_line:Nn #1 {#2} } +\RenewDocumentCommand \newline { } + { \galley_break_line:Nn \c_true_bool { 0 pt } } +% \end{macrocode} +%\end{macro} +%\end{macro} +% % \subsection{\LaTeXe{} fixes} % % Purely for testing, some internal \LaTeXe{} functions are altered to work @@ -2217,6 +2280,14 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\@normalcr} +% This is needed as \cs{@parboxrestore} sets |\\| equal to \cs{@normalcr}, +% and the new definition must be used +% \begin{macrocode} +\cs_set_eq:Nc \@normalcr { \token_to_str:N \\ } +% \end{macrocode} +%\end{macro} +% % \begin{macrocode} %</package> % \end{macrocode} |