From c9e4d3609b9024d4f14214ed64e9ee63b445e82b Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Sat, 15 Feb 2020 22:16:00 +0000
Subject: sdaps (15feb20)

git-svn-id: svn://tug.org/texlive/trunk@53795 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/sdaps/sdapsarray.sty | 61 ++++++++++++++++--------
 1 file changed, 42 insertions(+), 19 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/sdaps/sdapsarray.sty')

diff --git a/Master/texmf-dist/tex/latex/sdaps/sdapsarray.sty b/Master/texmf-dist/tex/latex/sdaps/sdapsarray.sty
index c57c389b347..3cbe705ab3c 100644
--- a/Master/texmf-dist/tex/latex/sdaps/sdapsarray.sty
+++ b/Master/texmf-dist/tex/latex/sdaps/sdapsarray.sty
@@ -11,12 +11,10 @@
 %% Copyright (C) 2015 by Benjamin Berg <benjamin@sipsolutions.net>
 %% 
 %% This work may be distributed and/or modified under the
-%% conditions of the LaTeX Project Public License, either version 1.3
+%% conditions of the LaTeX Project Public License, either version 1.3c
 %% of this license or (at your option) any later version.
 %% The latest version of this license is in
 %%   http://www.latex-project.org/lppl.txt
-%% and version 1.3 or later is part of all distributions of LaTeX
-%% version 2005/12/01 or later.
 %% 
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{sdapsarray}
@@ -149,6 +147,11 @@
 
   \keys_set:nf { sdaps / array } { \prop_item:Nn \g__sdaps_array_layouter_prop { #1 } }
 
+  % Force cell layouter instead of column header layouter
+  \bool_if:NT \l_sdaps_sdapsarray_no_header_bool {
+    \tl_set:NV \l__sdaps_array_colhead_tl \l__sdaps_array_cell_tl
+  }
+
   \_sdaps_array_open_tmpfiles:
 
   \tl_gset_eq:NN \g__sdaps_array_last_row_tl \c_empty_tl
@@ -240,33 +243,49 @@
     \msg_error:nn { sdapsarray } { wrong_mode }
   \fi
 
-  % Pagebreak detection
-  \_sdaps_array_check_insert_header:N \g_tmpa_bool
   % XXX: \l_tmpa_dim is the height to the first baseline in the box. Note that
   %      we use the real baseline in the case of the header row!
   \l__sdaps_array_row_tl #1 #2 \l_tmpb_box \l_tmpa_dim
 
-  \bool_if:NT \g_sdaps_array_first_row_bool {
-    % Stow away the box for later use (before rewriting it to save the position)
+  \bool_if:nTF { \g_sdaps_array_first_row_bool && !\l_sdaps_sdapsarray_no_header_bool } {
+    % Stow away the box for later use
     \box_gset_eq:NN \g__sdaps_array_header_box \l_tmpb_box
     \dim_gset:Nn \g__sdaps_array_header_dim { \box_ht:N \g__sdaps_array_header_box + \box_dp:N \g__sdaps_array_header_box }
+  } {
+    % Pagebreak detection (not needed for header row)
+    \_sdaps_array_check_insert_header:N \g_tmpa_bool
+
+    \hbox_set:Nn \l_tmpb_box {
+      \pdfsavepos
+      \iow_shipout_x:Nn \g__sdaps_array_info_iow {
+        \thepage,
+        \the\pdflastxpos
+      }
+      \box_use:N \l_tmpb_box
+    }
   }
 
-  \hbox_set:Nn \l_tmpb_box {
-    \pdfsavepos
-    \iow_shipout_x:Nn \g__sdaps_array_info_iow {
-      \thepage,
-      \the\pdflastxpos
+  \bool_if:nTF { \g_sdaps_array_first_row_bool || \l_sdaps_sdapsarray_no_header_bool } {
+    \_sdaps_array_calc_interlineskip:nnN { \prevdepth } { \l_tmpa_dim } \l_tmpa_skip
+    \nointerlineskip
+    \skip_vertical:n { \l_tmpa_skip }
+
+    % However do not insert the rowskip in the case of the first line.
+    % We rely on surrounding code to insert proper spacing before/after
+    % the environment.
+    \bool_if:NT \g_sdaps_array_first_row_bool {
+      \skip_vertical:n { - \l_sdaps_sdapsarray_rowsep_dim }
     }
+
     \box_use:N \l_tmpb_box
-  }
+    % For the header, insert a \nobreak, otherwise the normal inter-row penalty
+    \bool_if:NTF \l_sdaps_sdapsarray_no_header_bool {
+      \penalty\int_use:N\g_sdaps_array_row_penalty_tl
+    } {
+      \nobreak
+    }
 
-  \bool_if:NTF \g_sdaps_array_first_row_bool {
     \bool_gset_false:N \g_sdaps_array_first_row_bool
-
-    \box_use:N \l_tmpb_box
-    % Do not ever allow a break after the header line.
-    \nobreak
   } {
     % The idea is simple. Before every line the header is re-inserted (either
     % the real one or an empty box with the same dimensions). In the case that
@@ -623,6 +642,7 @@
 \tl_new:N \l_sdaps_sdapsarray_angle_sine_tl
 \dim_new:N \l_sdaps_sdapsarray_colsep_dim
 \dim_new:N \l_sdaps_sdapsarray_rowsep_dim
+\bool_new:N \l_sdaps_sdapsarray_no_header_bool
 
 \keys_define:nn { sdaps / sdapsarray }
 {
@@ -636,6 +656,9 @@
   keepenv    .bool_set:N   = \l_sdaps_sdapsarray_keepenv_bool,
   keepenv    .initial:n  = false,
   keepenv    .default:n  = true,
+  no_header  .bool_set:N = \l_sdaps_sdapsarray_no_header_bool,
+  no_header  .initial:n  = false,
+  no_header  .default:n  = true,
 
   angle          .code:n     = {
     \int_set:Nn \l_sdaps_sdapsarray_angle_int {#1}
@@ -957,7 +980,7 @@
   % (i.e. it could still be an alignment character). Execute the alignment
   % code directly if the next character is &.
   \bool_if:NF \l_sdaps_sdapsarray_keepenv_bool {
-    \peek_charcode_remove:NT & { \sdaps_array_alignment: }
+    \peek_charcode_remove_ignore_spaces:NT & { \sdaps_array_alignment: }
   }
 }
 {
-- 
cgit v1.2.3

