0

This is another follow up to this question.

My current \blap macro works in tabularx X columns with the article class. But it behaves slightly differently with the memoir class. Specifically, the vertical correction of \vspace*{-\parskip}\vspace*{-\baselineskip} seems not to be needed with memoir in this case. (This vertical correction is still needed in other contexts outside of tables in memoir, so I can't get rid of it completely.)

memoir emulates tabularx but using it's method to use the real tabularx package does not make a difference. i.e., this doesn't make any difference:

\DisemulatePackage{tabularx}
\usepackage{tabularx}

Question

Can anyone suggest a fix?

I'm happy with either a workaround, a patch to memoir, or a robust way to test if I'm in an X column cell, so I can conditionally leave out the \vspace*{-\parskip}\vspace*{-\baselineskip}.

MWE

\documentclass[twocolumn]{memoir}% works as intended with article
\usepackage{ifluatex}
\ifluatex
  \usepackage{lua-visual-debug}
\fi
\usepackage{tabularx}
\newskip\savedparindent
\newskip\savedparskip
\newskip\savedrightskip
\newcommand{\blap}[1]{%
  \savedparindent\parindent
  \savedparskip\parskip
  \savedrightskip\rightskip
  \noindent
  \begin{minipage}[t][0pt]{\linewidth}
    \parindent\savedparindent
    \parskip\savedparskip
    \rightskip\savedrightskip
    #1%
  \end{minipage}%
  % The following line is generally needed to line things up
  % but not in X columns in memoir (article is OK)
  \vspace*{-\parskip}\vspace*{-\baselineskip}%
}
\pagestyle{empty}
\begin{document}
\noindent
\begin{tabularx}{\linewidth}{lX}
  A1 & \blap{B1} \\[1cm]
  A2 & A2 \\[1cm]
\end{tabularx}
\newpage
\noindent
\begin{tabularx}{\linewidth}{lX}
  A1 & B1 \\[1cm]
  A2 & A2 \\[1cm]
\end{tabularx}
\end{document}
David Purton
  • 25,884

1 Answers1

1

Too long for comment. Until I get around to actually removing array and tabularx from memoir, this seems to work on TL18.

\documentclass[twocolumn]{memoir}% works as intended with article
\usepackage{ifluatex}
\ifluatex
  \usepackage{lua-visual-debug}
\fi

\DisemulatePackage{array}
\DisemulatePackage{tabularx}
\let\extratabsurround\relax
\makeatletter
\let\backup@length\relax
\let\firsthline\relax
\let\lasthline\relax
\def\@xhline{\ifx\reserved@a\hline
               \vskip\doublerulesep
               \vskip-\arrayrulewidth
             \fi
      \ifnum0=`{\fi}}
\newcommand\undefcolumntype[1]{\expandafter\let\csname NC@find@#1\endcsname\relax}
\newcommand\forcenewcolumntype[1]{\undefcolumntype{#1}\newcolumntype{#1}}
\undefcolumntype{X}
\undefcolumntype{*}
\makeatother
\usepackage{array,tabularx}

\newskip\savedparindent
\newskip\savedparskip
\newskip\savedrightskip
\newcommand{\blap}[1]{%
  \savedparindent\parindent
  \savedparskip\parskip
  \savedrightskip\rightskip
  \noindent
  \begin{minipage}[t][0pt]{\linewidth}
    \parindent\savedparindent
    \parskip\savedparskip
    \rightskip\savedrightskip
    #1%
  \end{minipage}%
  % The following line is generally needed to line things up
  % but not in X columns in memoir (article is OK)
  \vspace*{-\parskip}\vspace*{-\baselineskip}%
}
\pagestyle{empty}
\begin{document}
\noindent
\begin{tabularx}{\linewidth}{lX}
  A1 & \blap{B1} \\[1cm]
  A2 & A2 \\[1cm]
\end{tabularx}
\newpage
\noindent
\begin{tabularx}{\linewidth}{lX}
  A1 & B1 \\[1cm]
  A2 & A2 \\[1cm]
\end{tabularx}
\end{document}

I just kept relaxing stuff until it did not complain anymore. The code for removing a defined column type is from here: https://tex.stackexchange.com/a/157062/3929

daleif
  • 54,450