表格环境中的可选条目

表格环境中的可选条目

我需要将与桥梁相关的宏组合在一起以生成完整的桥梁图。下面显示了 MWE 和示例输出:

%********************************************************************************
\documentclass[10pt]{article}
\usepackage[paperwidth=6in,paperheight=9in, margin=1in]{geometry}
\usepackage{MnSymbol}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{xparse}
\usepackage{tikz}
\usepackage{libertine}
\usepackage{array}
%********************************************************************************


%********************************************************************************
% Use MnSymbol suit symbols

\DeclareFontFamily{U}{MnSymbolCards}{}

\DeclareFontShape{U}{MnSymbolCards}{m}{n}{
    <-6>  s*[1.1] MnSymbolC5
   <6-7>  s*[1.1] MnSymbolC6
   <7-8>  s*[1.1] MnSymbolC7
   <8-9>  s*[1.1] MnSymbolC8
   <9-10> s*[1.1] MnSymbolC9
  <10-12> s*[1.1] MnSymbolC10
  <12->   s*[1.1] MnSymbolC12}{}

\newcommand{\mndiamond}{{\usefont{U}{MnSymbolCards}{m}{n}\symbol{"A2}}}
\newcommand{\mnheart}{{\usefont{U}{MnSymbolCards}{m}{n}\symbol{"A3}}}
\newcommand{\mnspade}{{\usefont{U}{MnSymbolCards}{m}{n}\symbol{"A4}}}
\newcommand{\mnclub}{{\usefont{U}{MnSymbolCards}{m}{n}\symbol{"A5}}}
%********************************************************************************


%********************************************************************************
% BRIDGE HAND
%********************************************************************************
\newcommand{\cardsep}{\hspace*{0.2em}}

% Defines a vertical bridge hand with seat name
\ExplSyntaxOn
\NewDocumentCommand{\hand}{sO{S,H,D,C}mm}
 {
  \IfBooleanTF{#1}
   {
    \blackened_hand_horizontal:nnn { #2 } { #3 } { #4 }
   }
   {
    \blackened_hand:nnn { #2 } { #3 } { #4 }
   }
 }

\seq_new:N \l_blackened_hand_seq
\clist_new:N \l_blackened_suit_clist

\cs_new_protected:Nn \blackened_hand_horizontal:nnn
 {
  \seq_set_split:Nnn \l_blackened_hand_seq { ; } { #3 }
  \hspace*{-1em}% remove the initial \quad
  \clist_if_in:nnT { #1 } { S }
   { \quad \mbox{\mnspade   \ \blackened_set_suit:n { 1 } } }
  \clist_if_in:nnT { #1 } { H }
   { \quad \mbox{\mnheart   \ \blackened_set_suit:n { 2 } } }
  \clist_if_in:nnT { #1 } { D }
   { \quad \mbox{\mndiamond \ \blackened_set_suit:n { 3 } } }
  \clist_if_in:nnT { #1 } { C }
   { \quad \mbox{\mnclub    \ \blackened_set_suit:n { 4 } } }
 }

\cs_new_protected:Nn \blackened_hand:nnn
 {
  \seq_set_split:Nnn \l_blackened_hand_seq { ; } { #3 }
  \bool_gset_false:N \g_blackened_newline_bool
  \begin{minipage}{\textwidth}
  \begin{tabbing}
  \tl_if_blank:nTF { #2 }
    { \bool_gset_false:N \g_blackened_newline_bool }
    { \bool_gset_true:N \g_blackened_newline_bool \textbf{#2} }
  \clist_if_in:nnT { #1 } { S }
   { \blackened_newline: \mnspade   \= \cardsep \= \blackened_set_suit:n { 1 } }
  \clist_if_in:nnT { #1 } { H }
   { \blackened_newline: \mnheart   \= \cardsep \= \blackened_set_suit:n { 2 } }
  \clist_if_in:nnT { #1 } { D }
   { \blackened_newline: \mndiamond \= \cardsep \= \blackened_set_suit:n { 3 } }
  \clist_if_in:nnT { #1 } { C }
   { \blackened_newline: \mnclub    \= \cardsep \= \blackened_set_suit:n { 4 } }
  \end{tabbing}
  \end{minipage}
  \bool_gset_false:N \g_blackened_newline_bool
 }

\tl_const:Nn \c_blackened_ten_tl { 10 }
\tl_new:N \l_blackened_suit_tl
\seq_new:N \l_blackened_suit_seq
\bool_new:N \g_blackened_newline_bool

\cs_new_protected:Nn \blackened_newline:
 {
  \bool_if:NTF \g_blackened_newline_bool
   { \\ }
   { \bool_gset_true:N \g_blackened_newline_bool }
 }

\cs_new_protected:Nn \blackened_set_suit:n
 {
  \tl_set:Nx \l_blackened_suit_tl { \seq_item:Nn \l_blackened_hand_seq { #1 } }
  \tl_if_blank:VTF \l_blackened_suit_tl
   { --- } % no card in the suit
   {
    \tl_replace_once:Nnn \l_blackened_suit_tl { 10 } { \c_blackened_ten_tl }
    \seq_set_split:NnV \l_blackened_suit_seq { } \l_blackened_suit_tl
    \seq_use:Nn \l_blackened_suit_seq { \cardsep }
   }
 }
\ExplSyntaxOff
%********************************************************************************

% Above macros are not directly related to this question,
% they are needed to to produce the diagrams


%********************************************************************************
% BRIDGE DIAGRAM
%********************************************************************************
\newlength{\myminipageparskip}
\newenvironment{bdminipage}
  {\setlength{\myminipageparskip}{1ex}% save the value
   \begin{minipage}[t]{3in}% open the minipage
   \setlength{\parskip}{\myminipageparskip}% restore the value
  }
  {\end{minipage}}

% bidding
\newenvironment{bidding}{%
\begin{minipage}[t]{3in}
\setlength{\topsep}{0pt}%
\setlength{\partopsep}{0pt}%
\begin{tabbing}
\hspace*{0.75in}\= \hspace*{0.75in}\= \hspace*{0.75in}\= \hspace*{0.75in} \kill
\textbf{South} \> \textbf{West} \> \textbf{North} \> \textbf{East}\\
}%
{\end{tabbing}\end{minipage}}%


\newcommand{\bdcomplete}[7]{%
\begin{tabular}[t]{ m{1in} m{1in} m{1in}}
\multicolumn{3}{m{3in}}{
\begin{bdminipage}
#1
\end{bdminipage}}\vspace{2ex}\\
   & #2 &\\
#3 & {\begin{tikzpicture} \draw (0,0) rectangle (1.3,1.3); \end{tikzpicture}} & #4\\
   & #5 &\\
\multicolumn{3}{m{3in}}{#6}\\
\multicolumn{3}{m{3in}}{
\begin{bdminipage}
#7
\end{bdminipage}}
\end{tabular}
}
%********************************************************************************




\begin{document}

The following deal was reported in the \emph{The Bridge World} magazine:

\begin{center}
\bdcomplete
{
East dealer,\\
North-South vulnerable
}
{\hand{North}{J432; 65; A53; QJ109}}%
{\hand{West}{K5; AK9732; 84; 876}}%
{\hand{East}{109876; J84; J; K532}}%
{\hand{South}{AQ; Q10; KQ109762; A4}}%
{
\begin{bidding}
2\mnheart \> Pass\> 3\mnheart \> Double \\
Pass\> 3\mnspade \> Pass \> 4\mndiamond \\
Pass\> 5\mndiamond\> Pass\> Pass\\
Pass
\end{bidding}
}
{
Contract: Five-clubs doubled by South.

Opening lead: Heart ace.

Closed Room Result: Five clubs doubled by the Brazilian South, down 1, +100 for Norway.
}
\end{center}
Some text following the diagram above.

\end{document}

在此处输入图片描述

当某些选项为空白时,它们仍然占据一定的垂直空间,如下所示:

\begin{document}

The following deal was reported in the \emph{The Bridge World} magazine:

\begin{center}
\bdcomplete
{}
{\hand{North}{J432; 65; A53; QJ109}}%
{\hand{West}{K5; AK9732; 84; 876}}%
{\hand{East}{109876; J84; J; K532}}%
{\hand{South}{AQ; Q10; KQ109762; A4}}%
{}{}
\end{center}
Some text following the diagram above.

在此处输入图片描述

我怎样才能避免这种行为?

(当我“感觉”这些宏已经成熟时,我计划将它们展示给桥牌作者、玩家等。因此,任何评论都可以桥梁图上面的宏更强大,更符合 LaTeX 方式,更灵活,任何方式都值得赞赏。例如,投标和下面的说明文字之间没有足够的垂直空间;我希望能够尽可能地控制这些细节。)

(我知道我可以为不同的图表和需求编写单独的宏。)

答案1

可以使用\notblank{#1}{true}{false}frometoolbox包来查询参数是否为空并做出相应的反应。但是,不应在包内使用它,因为无论是否为空,\multicolumn这些表格单元格都会以任何方式排版。#1

使用

\noalign{\gdef\temp@x{\notblank{#1}{\multicolumn{3}{m{3in}}{%... }}{\@empty}}}\temp@x

这将首先屏蔽查询(\noalign)并存储执行,\temp@x然后调用该执行。如果\temp@x为空,则不执行任何操作。

当为空时,会有额外的垂直空间#6-->\tabularnewline无论如何都会使用 a。我用 a 删除了它\showonlyifnotempty{#6}

#1#7的代码bdminipage几乎相同,因此我定义了\showwithminipage{som},带星号的版本用于抑制\tabularnewline末尾的\multicolumn。如果没有给出可选参数,则不会\vspace{...}插入 。

应对的另一种可能性{}是使用可选参数,而\NewDocumentCommand不是查询,\IfValueT但这并不妨碍这种\noalign方法。

%********************************************************************************
\documentclass[10pt]{article}
\usepackage[paperwidth=6in,paperheight=9in, margin=1in]{geometry}
\usepackage{MnSymbol}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{etoolbox}
\usepackage{xparse}
\usepackage{tikz}
\usepackage{libertine}
\usepackage{array}
%********************************************************************************


%********************************************************************************
% Use MnSymbol suit symbols

\DeclareFontFamily{U}{MnSymbolCards}{}

\DeclareFontShape{U}{MnSymbolCards}{m}{n}{
    <-6>  s*[1.1] MnSymbolC5
   <6-7>  s*[1.1] MnSymbolC6
   <7-8>  s*[1.1] MnSymbolC7
   <8-9>  s*[1.1] MnSymbolC8
   <9-10> s*[1.1] MnSymbolC9
  <10-12> s*[1.1] MnSymbolC10
  <12->   s*[1.1] MnSymbolC12}{}

\newcommand{\mndiamond}{{\usefont{U}{MnSymbolCards}{m}{n}\symbol{"A2}}}
\newcommand{\mnheart}{{\usefont{U}{MnSymbolCards}{m}{n}\symbol{"A3}}}
\newcommand{\mnspade}{{\usefont{U}{MnSymbolCards}{m}{n}\symbol{"A4}}}
\newcommand{\mnclub}{{\usefont{U}{MnSymbolCards}{m}{n}\symbol{"A5}}}
%********************************************************************************


%********************************************************************************
% BRIDGE HAND
%********************************************************************************
\newcommand{\cardsep}{\hspace*{0.2em}}

% Defines a vertical bridge hand with seat name
\ExplSyntaxOn
\NewDocumentCommand{\hand}{sO{S,H,D,C}mm}
 {
  \IfBooleanTF{#1}
   {
    \blackened_hand_horizontal:nnn { #2 } { #3 } { #4 }
   }
   {
    \blackened_hand:nnn { #2 } { #3 } { #4 }
   }
 }

\seq_new:N \l_blackened_hand_seq
\clist_new:N \l_blackened_suit_clist

\cs_new_protected:Nn \blackened_hand_horizontal:nnn
 {
  \seq_set_split:Nnn \l_blackened_hand_seq { ; } { #3 }
  \hspace*{-1em}% remove the initial \quad
  \clist_if_in:nnT { #1 } { S }
   { \quad \mbox{\mnspade   \ \blackened_set_suit:n { 1 } } }
  \clist_if_in:nnT { #1 } { H }
   { \quad \mbox{\mnheart   \ \blackened_set_suit:n { 2 } } }
  \clist_if_in:nnT { #1 } { D }
   { \quad \mbox{\mndiamond \ \blackened_set_suit:n { 3 } } }
  \clist_if_in:nnT { #1 } { C }
   { \quad \mbox{\mnclub    \ \blackened_set_suit:n { 4 } } }
 }

\cs_new_protected:Nn \blackened_hand:nnn
 {
  \seq_set_split:Nnn \l_blackened_hand_seq { ; } { #3 }
  \bool_gset_false:N \g_blackened_newline_bool
  \begin{minipage}{\textwidth}
  \begin{tabbing}
  \tl_if_blank:nTF { #2 }
    { \bool_gset_false:N \g_blackened_newline_bool }
    { \bool_gset_true:N \g_blackened_newline_bool \textbf{#2} }
  \clist_if_in:nnT { #1 } { S }
   { \blackened_newline: \mnspade   \= \cardsep \= \blackened_set_suit:n { 1 } }
  \clist_if_in:nnT { #1 } { H }
   { \blackened_newline: \mnheart   \= \cardsep \= \blackened_set_suit:n { 2 } }
  \clist_if_in:nnT { #1 } { D }
   { \blackened_newline: \mndiamond \= \cardsep \= \blackened_set_suit:n { 3 } }
  \clist_if_in:nnT { #1 } { C }
   { \blackened_newline: \mnclub    \= \cardsep \= \blackened_set_suit:n { 4 } }
  \end{tabbing}
  \end{minipage}
  \bool_gset_false:N \g_blackened_newline_bool
 }

\tl_const:Nn \c_blackened_ten_tl { 10 }
\tl_new:N \l_blackened_suit_tl
\seq_new:N \l_blackened_suit_seq
\bool_new:N \g_blackened_newline_bool

\cs_new_protected:Nn \blackened_newline:
 {
  \bool_if:NTF \g_blackened_newline_bool
   { \\ }
   { \bool_gset_true:N \g_blackened_newline_bool }
 }

\cs_new_protected:Nn \blackened_set_suit:n
 {
  \tl_set:Nx \l_blackened_suit_tl { \seq_item:Nn \l_blackened_hand_seq { #1 } }
  \tl_if_blank:VTF \l_blackened_suit_tl
   { --- } % no card in the suit
   {
    \tl_replace_once:Nnn \l_blackened_suit_tl { 10 } { \c_blackened_ten_tl }
    \seq_set_split:NnV \l_blackened_suit_seq { } \l_blackened_suit_tl
    \seq_use:Nn \l_blackened_suit_seq { \cardsep }
   }
 }
\ExplSyntaxOff
%********************************************************************************

% Above macros are not directly related to this question,
% they are needed to to produce the diagrams


%********************************************************************************
% BRIDGE DIAGRAM
%********************************************************************************
\newlength{\myminipageparskip}
\newenvironment{bdminipage}
{\setlength{\myminipageparskip}{1ex}% save the value
  \begin{minipage}[t]{3in}% open the minipage
    \setlength{\parskip}{\myminipageparskip}% restore the value
  }
  {\end{minipage}}

% bidding
\newenvironment{bidding}{%
\begin{minipage}[t]{3in}
\setlength{\topsep}{0pt}%
\setlength{\partopsep}{0pt}%
\begin{tabbing}
\hspace*{0.75in}\= \hspace*{0.75in}\= \hspace*{0.75in}\= \hspace*{0.75in} \kill
\textbf{South} \> \textbf{West} \> \textbf{North} \> \textbf{East}\\
}%
{\end{tabbing}\end{minipage}}%

\makeatletter
\newcommand{\showonlyifnotempty}[1]{%
  \noalign{%
    \gdef\temp@x{\notblank{#1}{%
        \multicolumn{3}{m{3in}}{#1}
        \tabularnewline
      }{% false branch
        \@empty
      }%
    }%
  }%
  \temp@x
}

\DeclareExpandableDocumentCommand{\showwithminipage}{som}{%
  \noalign{%
    \gdef\temp@x{\notblank{#3}{%
        \multicolumn{3}{m{3in}}{%
          \begin{bdminipage}
            #3
          \end{bdminipage}
          \IfValueT{#2}{%
          \vspace{#2}%
          }
        }
        \IfBooleanF{#1}{%
        \tabularnewline % Only \tabularnewline if there is no star
        }%
      }{% false branch
        \@empty
      }%
    }%
  }%
  \temp@x
}




\NewDocumentCommand{\bdcomplete}{mmmmmmm}{%
\begin{tabular}[t]{ m{1in} m{1in} m{1in}}
  \showwithminipage[2ex]{#1}
  & #2 & \\
  #3 & {\begin{tikzpicture} \draw (0,0) rectangle (1.3,1.3); \end{tikzpicture}} & #4\\
  & #5 & \tabularnewline
  \showonlyifnotempty{#6}%
  \showwithminipage*{#7} 
 \end{tabular}%
}
\makeatother
%********************************************************************************





\begin{document}

The following deal was reported in the \emph{The Bridge World} magazine:
\hrule
\begin{center}
\bdcomplete
{Hello}
{\hand{North}{J432; 65; A53; QJ109}}%
{\hand{West}{K5; AK9732; 84; 876}}%
{\hand{East}{109876; J84; J; K532}}%
{\hand{South}{AQ; Q10; KQ109762; A4}}%
{More Text}{Even more text}
\end{center}
\hrule
\begin{center}
\bdcomplete
{}
{\hand{North}{J432; 65; A53; QJ109}}%
{\hand{West}{K5; AK9732; 84; 876}}%
{\hand{East}{109876; J84; J; K532}}%
{\hand{South}{AQ; Q10; KQ109762; A4}}%
{}{}
\end{center}
\hrule
Some text following the diagram above.

\end{document}

在此处输入图片描述

编辑long带有允许标准打破的参数的版本:

%********************************************************************************
\documentclass[10pt]{article}
\usepackage[paperwidth=6in,paperheight=9in, margin=1in]{geometry}
\usepackage{MnSymbol}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{etoolbox}
\usepackage{xparse}
\usepackage{tikz}
\usepackage{libertine}
\usepackage{array}
%********************************************************************************


%********************************************************************************
% Use MnSymbol suit symbols

\DeclareFontFamily{U}{MnSymbolCards}{}

\DeclareFontShape{U}{MnSymbolCards}{m}{n}{
    <-6>  s*[1.1] MnSymbolC5
   <6-7>  s*[1.1] MnSymbolC6
   <7-8>  s*[1.1] MnSymbolC7
   <8-9>  s*[1.1] MnSymbolC8
   <9-10> s*[1.1] MnSymbolC9
  <10-12> s*[1.1] MnSymbolC10
  <12->   s*[1.1] MnSymbolC12}{}

\newcommand{\mndiamond}{{\usefont{U}{MnSymbolCards}{m}{n}\symbol{"A2}}}
\newcommand{\mnheart}{{\usefont{U}{MnSymbolCards}{m}{n}\symbol{"A3}}}
\newcommand{\mnspade}{{\usefont{U}{MnSymbolCards}{m}{n}\symbol{"A4}}}
\newcommand{\mnclub}{{\usefont{U}{MnSymbolCards}{m}{n}\symbol{"A5}}}
%********************************************************************************


%********************************************************************************
% BRIDGE HAND
%********************************************************************************
\newcommand{\cardsep}{\hspace*{0.2em}}

% Defines a vertical bridge hand with seat name
\ExplSyntaxOn
\NewDocumentCommand{\hand}{sO{S,H,D,C}mm}
 {
  \IfBooleanTF{#1}
   {
    \blackened_hand_horizontal:nnn { #2 } { #3 } { #4 }
   }
   {
    \blackened_hand:nnn { #2 } { #3 } { #4 }
   }
 }

\seq_new:N \l_blackened_hand_seq
\clist_new:N \l_blackened_suit_clist

\cs_new_protected:Nn \blackened_hand_horizontal:nnn
 {
  \seq_set_split:Nnn \l_blackened_hand_seq { ; } { #3 }
  \hspace*{-1em}% remove the initial \quad
  \clist_if_in:nnT { #1 } { S }
   { \quad \mbox{\mnspade   \ \blackened_set_suit:n { 1 } } }
  \clist_if_in:nnT { #1 } { H }
   { \quad \mbox{\mnheart   \ \blackened_set_suit:n { 2 } } }
  \clist_if_in:nnT { #1 } { D }
   { \quad \mbox{\mndiamond \ \blackened_set_suit:n { 3 } } }
  \clist_if_in:nnT { #1 } { C }
   { \quad \mbox{\mnclub    \ \blackened_set_suit:n { 4 } } }
 }

\cs_new_protected:Nn \blackened_hand:nnn
 {
  \seq_set_split:Nnn \l_blackened_hand_seq { ; } { #3 }
  \bool_gset_false:N \g_blackened_newline_bool
  \begin{minipage}{\textwidth}
  \begin{tabbing}
  \tl_if_blank:nTF { #2 }
    { \bool_gset_false:N \g_blackened_newline_bool }
    { \bool_gset_true:N \g_blackened_newline_bool \textbf{#2} }
  \clist_if_in:nnT { #1 } { S }
   { \blackened_newline: \mnspade   \= \cardsep \= \blackened_set_suit:n { 1 } }
  \clist_if_in:nnT { #1 } { H }
   { \blackened_newline: \mnheart   \= \cardsep \= \blackened_set_suit:n { 2 } }
  \clist_if_in:nnT { #1 } { D }
   { \blackened_newline: \mndiamond \= \cardsep \= \blackened_set_suit:n { 3 } }
  \clist_if_in:nnT { #1 } { C }
   { \blackened_newline: \mnclub    \= \cardsep \= \blackened_set_suit:n { 4 } }
  \end{tabbing}
  \end{minipage}
  \bool_gset_false:N \g_blackened_newline_bool
 }

\tl_const:Nn \c_blackened_ten_tl { 10 }
\tl_new:N \l_blackened_suit_tl
\seq_new:N \l_blackened_suit_seq
\bool_new:N \g_blackened_newline_bool

\cs_new_protected:Nn \blackened_newline:
 {
  \bool_if:NTF \g_blackened_newline_bool
   { \\ }
   { \bool_gset_true:N \g_blackened_newline_bool }
 }

\cs_new_protected:Nn \blackened_set_suit:n
 {
  \tl_set:Nx \l_blackened_suit_tl { \seq_item:Nn \l_blackened_hand_seq { #1 } }
  \tl_if_blank:VTF \l_blackened_suit_tl
   { --- } % no card in the suit
   {
    \tl_replace_once:Nnn \l_blackened_suit_tl { 10 } { \c_blackened_ten_tl }
    \seq_set_split:NnV \l_blackened_suit_seq { } \l_blackened_suit_tl
    \seq_use:Nn \l_blackened_suit_seq { \cardsep }
   }
 }
\ExplSyntaxOff
%********************************************************************************

% Above macros are not directly related to this question,
% they are needed to to produce the diagrams


%********************************************************************************
% BRIDGE DIAGRAM
%********************************************************************************
\newlength{\myminipageparskip}
\newenvironment{bdminipage}
{\setlength{\myminipageparskip}{1ex}% save the value
  \begin{minipage}[t]{3in}% open the minipage
    \setlength{\parskip}{\myminipageparskip}% restore the value
  }
  {\end{minipage}}

% bidding
\newenvironment{bidding}{%
\begin{minipage}[t]{3in}
\setlength{\topsep}{0pt}%
\setlength{\partopsep}{0pt}%
\begin{tabbing}
\hspace*{0.75in}\= \hspace*{0.75in}\= \hspace*{0.75in}\= \hspace*{0.75in} \kill
\textbf{South} \> \textbf{West} \> \textbf{North} \> \textbf{East}\\
}%
{\end{tabbing}\end{minipage}}%

\makeatletter
\newcommand{\showonlyifnotempty}[1]{%
  \noalign{%
    \gdef\temp@x{\notblank{#1}{%
        \multicolumn{3}{m{3in}}{#1}
        \tabularnewline
      }{% false branch
        \@empty
      }%
    }%
  }%
  \temp@x
}

\DeclareExpandableDocumentCommand{\showwithminipage}{+s+o+m}{%
  \noalign{%
    \gdef\temp@x{\notblank{#3}{%
        \multicolumn{3}{m{3in}}{%
          \begin{bdminipage}
            #3
          \end{bdminipage}
          \IfValueT{#2}{%
          \vspace{#2}%
          }
        }
        \IfBooleanF{#1}{%
        \tabularnewline % Only \tabularnewline if there is no star
        }%
      }{% false branch
        \@empty
      }%
    }%
  }%
  \temp@x
}




\NewDocumentCommand{\bdcomplete}{+m+m+m+m+m+m+m}{%
\begin{tabular}[t]{ m{1in} m{1in} m{1in}}
  \showwithminipage[2ex]{#1}
  & #2 & \\
  #3 & {\begin{tikzpicture} \draw (0,0) rectangle (1.3,1.3); \end{tikzpicture}} & #4\\
  & #5 & \tabularnewline
  \showonlyifnotempty{#6}%
  \showwithminipage*{#7} 
 \end{tabular}%
}
\makeatother
%********************************************************************************






\begin{document}

The following deal was reported in the \emph{The Bridge World} magazine:

\begin{center}
\bdcomplete
{
East dealer,\\
North-South vulnerable
}
{\hand{North}{J432; 65; A53; QJ109}}%
{\hand{West}{K5; AK9732; 84; 876}}%
{\hand{East}{109876; J84; J; K532}}%
{\hand{South}{AQ; Q10; KQ109762; A4}}%
{
\begin{bidding}
2\mnheart \> Pass\> 3\mnheart \> Double \\
Pass\> 3\mnspade \> Pass \> 4\mndiamond \\
Pass\> 5\mndiamond\> Pass\> Pass\\
Pass
\end{bidding}
}
{
Contract: Five-clubs doubled by South.

Opening lead: Heart ace.

Closed Room Result: Five clubs doubled by the Brazilian South, down 1, +100 for Norway.
}
\end{center}
Some text following the diagram above.

\end{document}


\begin{document}
The following deal was reported in the \emph{The Bridge World} magazine:
\hrule
\begin{center}
\bdcomplete
{Hello}
{\hand{North}{J432; 65; A53; QJ109}}%
{\hand{West}{K5; AK9732; 84; 876}}%
{\hand{East}{109876; J84; J; K532}}%
{\hand{South}{AQ; Q10; KQ109762; A4}}%
{More Text}{Even more text}
\end{center}
\hrule
\begin{center}
\bdcomplete
{}
{\hand{North}{J432; 65; A53; QJ109}}%
{\hand{West}{K5; AK9732; 84; 876}}%
{\hand{East}{109876; J84; J; K532}}%
{\hand{South}{AQ; Q10; KQ109762; A4}}%
{}{}
\end{center}
\hrule
Some text following the diagram above.



\end{document}

在此处输入图片描述

请求可选参数

\NewDocumentCommand{\bdcompleteopt}{+m+m+m+m+m+O{2ex}+m+O{1ex}+m}{%
\begin{tabular}[t]{ m{1in} m{1in} m{1in}}
  \showwithminipage[2ex]{#1}
  & #2 & \\
  #3 & {\begin{tikzpicture} \draw (0,0) rectangle (1.3,1.3); \end{tikzpicture}} & #4\\
  & #5 & \tabularnewline[#6] % Optional space between #5 and #7
  \showonlyifnotempty{#7}%
  \showwithminipage*[#8]{#9} % Optional space between next to last and last line
 \end{tabular}%
}

相关内容