我如何让我的卡片自动平铺?

我如何让我的卡片自动平铺?

我想制作几张用于游戏的扑克牌。没有已知的软件包, 然而窃取先前的答案并删除一些东西直到它有意义为止,这让我走到了这一步:

\documentclass{article}
\usepackage[margin=2cm]{geometry}

\newlength\cardheight
\newlength\cardwidth

\setlength\cardheight{0.25\textheight}
\setlength\cardwidth{0.4\textwidth}

\newcommand\cards[1]{%
\par\noindent
\fbox{\begin{minipage}[t][\cardheight][t]{\dimexpr\cardwidth-2\fboxsep-2\fboxrule\relax} 
\vspace{\baselineskip}
\LARGE ~ #1 
\vfill
\small ~ Cards Against Humanity %I should insert the CAH logo in my final version
\end{minipage}} %\par\bigskip%
} %


\pagestyle{empty}

\begin{document}
\centering
\cards{%
Classicist undertones.
}
\cards{%
A windmill full of corpses.
}
\cards{%
A tiny horse.
}

\end{document}

但是,这样会使三张卡片堆叠在一起。我怎样才能让它们自动平铺(所以它类似于 card:card:card,newrow card:card:card)?每页水平和垂直的卡片确切数量并不重要;我只希望每张卡片彼此相邻,而不是每张新卡片出现在新行上。

(如果有更好的方法可以做到这一点,请随意放弃我的代码:正如我所说,我只是从一个仅有一定相关性的例子中复制了它。)

答案1

只需删除\par\noindent即可。此外,该行中有一个虚假的空格

\end{minipage}} %\par\bigskip%

完整代码

\documentclass{article}
\usepackage[margin=2cm]{geometry}

\newlength\cardheight
\newlength\cardwidth

\setlength\cardheight{0.25\textheight}
\setlength\cardwidth{0.4\textwidth}

\newcommand\cards[1]{%
\fbox{\begin{minipage}[t][\cardheight][t]{\dimexpr\cardwidth-2\fboxsep-2\fboxrule\relax}
\vspace{\baselineskip}
\LARGE ~ #1
\vfill
\small ~ Cards Against Humanity %I should insert the CAH logo in my final version
\end{minipage}}% there was a space here
}


\pagestyle{empty}

\begin{document}
\centering
\cards{%
Classicist undertones.
}
\cards{%
A windmill full of corpses.
}
\cards{%
A tiny horse.
}
\cards{%
One more card.
}

\end{document} 

输出:

在此处输入图片描述

您可能还希望它们之间留出很小的水平空间。为了实现这一点,您可以\hspace{1pt}在 的末尾添加 ,并在每个 之后\fbox放置一个:%\cards

\documentclass{article}
\usepackage[margin=2cm]{geometry}

\newlength\cardheight
\newlength\cardwidth

\setlength\cardheight{0.25\textheight}
\setlength\cardwidth{0.4\textwidth}

\newcommand\cards[1]{%
\fbox{\begin{minipage}[t][\cardheight][t]{\dimexpr\cardwidth-2\fboxsep-2\fboxrule\relax}
\vspace{\baselineskip}
\LARGE ~ #1
\vfill
\small ~ Cards Against Humanity %I should insert the CAH logo in my final version
\end{minipage}}% there was a space here
\hspace{1pt}}


\pagestyle{empty}

\begin{document}
\centering
\cards{%
Classicist undertones.
}%
\cards{%
A windmill full of corpses.
}%
\cards{%
A tiny horse.
}%
\cards{%
One more card.
}%

\end{document} 

输出:

在此处输入图片描述

相关内容