我有一个文档,它正在为我制作卡片。一个简化的、几乎最小的示例如下所示
\documentclass{article}
\usepackage[utf8]{inputenc} %Needed for input
\usepackage{venturis} %CM does not look right at this size
\usepackage[T1]{fontenc} %Needed for output
\usepackage[margin=0.4cm]{geometry} %The layout gets screwed up if I don't include this.
\newlength\cardheight
\newlength\cardwidth
\setlength\cardheight{0.3\textheight}
\setlength\cardwidth{0.3\textwidth}
\setlength{\fboxsep}{20pt}
\newcommand\card[2]{%
\begingroup\fboxsep=10pt%
\fbox{\begin{minipage}[t][\cardheight][t]{\dimexpr\cardwidth-2\fboxsep-2\fboxrule\relax}%
\raggedright%
\vspace{0.5 \baselineskip}%
\LARGE #1%
\vfill%
\noindent \normalsize #2%
\end{minipage}}%
\hspace{1pt}%
\endgroup}%
\makeatletter%
\newcommand{\cards}[2]{%
\@for\@c:=#1\do{%
\card{\@c}{#2}%
}%
}%
\makeatother%
\newcommand{\blank}{\hrulefill}
\pagestyle{empty}
\begin{document}
\centering
\cards{%Basic set
A big hoopla about nothing,%
A wheelchair death race%
}{Cards Against Humanity: Googling this is probably a bad idea}%
\cards{%The Canadian Expansion
Burning down the White House,%
Terry Fox's prosthetic leg,%
{The Offical Languages Act \\\vspace{\baselineskip} \noindent La Loi sur les langues officielles.},%To show you some of my cards are a bit more complex
The Front de Libération du Québec,%
Poutine,%
Killing a Moose with your bare hands%
}{Cards Against Humanity:\\ The Canadian Expansion. No really, don't google this at work.}%
\cards{%The Second Expansion
A piñata full of scorpions%
}%
{Cards Against Humanity:\\The Second Expansion. This if a card game for horrible people.}%
\end{document}
如您所见,这可以完美地布置卡片的正面。但是,我希望卡片有背面。我该如何自动将包含卡片背面的页面与我选择的文本交错?这样,当我在双面打印机上打印时,我就能得到卡片的正面和背面。
编辑:澄清一下,这是我的文档的一页。我的实际文档中有 126 页,有多个 \card 命令,每个组一个。我不想手动设置那么多背景,所以我想要一个可以自动将文本“Cards Against Humanity”放在每张卡片背面的背景(即在每隔一页上,但放在有卡片的地方,这样卡片编号不均匀的页面仍然可以获得正确的背面。)
答案1
以下界面在列表宏中收集卡背,然后在您收集到 9 张卡背或以下时对其进行处理\AtDocumentEnd
:
\documentclass{article}
\usepackage[utf8]{inputenc} %Needed for input
\usepackage{venturis} %CM does not look right at this size
\usepackage[T1]{fontenc} %Needed for output
\usepackage[margin=0.4cm]{geometry} %The layout gets screwed up if I don't include this.
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox (for list processing)
\newlength\cardheight\setlength\cardheight{0.3\textheight}
\newlength\cardwidth\setlength\cardwidth{0.3\textwidth}
\newcounter{itemcnt}
\newcommand{\cardbacks}{}% List of card backs
\setlength{\fboxsep}{20pt}
\makeatletter
% http://tex.stackexchange.com/q/308/5764
\def\ifemptyarg#1{%
\if\relax\detokenize{#1}\relax % H. Oberdiek
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi}
\makeatother
\newcommand{\setcardcontent}[2]{{%
\setlength{\fboxsep}{10pt}%
\fbox{\begin{minipage}[t][\cardheight][t]{\dimexpr\cardwidth-2\fboxsep-2\fboxrule\relax}%
\raggedright%
\vspace{0.5 \baselineskip}%
\LARGE #1%
\vfill%
\noindent \normalsize #2%
\end{minipage}}%
\hspace{1pt}%
}}
\newcommand{\card}[3][Cards Against Humanity]{%
\ifemptyarg{#1}{}{\stepcounter{itemcnt}}% Another card has been added
\ifnum\value{itemcnt}>9\relax
\clearpage
\renewcommand*{\do}[1]{\setcardcontent{}{##1}}%
\dolistcsloop{cardbacks}% Set card backs
\renewcommand{\cardbacks}{}% Clear list
\clearpage
\setcounter{itemcnt}{1}% Restart counting cards
\fi%
\ifemptyarg{#1}{}{\listgadd{\cardbacks}{#1}}%
\setcardcontent{#2}{#3}%
}%
\makeatletter%
\newcommand{\cards}[3][Cards Against Humanity]{%
\@for\@c:=#2\do{%
\card[#1]{\@c}{#3}%
}%
}%
\makeatother%
\AtEndDocument{% Flush remainder of card backs
\clearpage
\renewcommand*{\do}[1]{\setcardcontent{}{#1}}%
\dolistcsloop{cardbacks}% Set card backs
}
\newcommand{\blank}{\hrulefill}
\pagestyle{empty}
\begin{document}
\centering
\cards{%Basic set
A big hoopla about nothing,%
A wheelchair death race%
}{Cards Against Humanity: Googling this is probably a bad idea}%
\cards{%The Canadian Expansion
Burning down the White House,%
Terry Fox's prosthetic leg,%
{The Offical Languages Act \\\vspace{\baselineskip}
\noindent La Loi sur les langues officielles.},%To show you some of my cards are a bit more complex
The Front de Libération du Québec,%
Poutine,%
Killing a Moose with your bare hands%
}{Cards Against Humanity:\par The Canadian Expansion. No really, don't Google this at work.}%
\cards{%The Second Expansion
A piñata full of scorpions%
}{Cards Against Humanity:\par The Second Expansion. This if a card game for horrible people.}%
\cards{%The Second Expansion
A piñata full of scorpions%
}{Cards Against Humanity:\par The Second Expansion. This if a card game for horrible people.}%
\cards{%The Canadian Expansion
Burning down the White House,%
Terry Fox's prosthetic leg,%
{The Offical Languages Act \\\vspace{\baselineskip}
\noindent La Loi sur les langues officielles.},%To show you some of my cards are a bit more complex
The Front de Libération du Québec,%
Poutine,%
Killing a Moose with your bare hands%
}{Cards Against Humanity:\par The Canadian Expansion. No really, don't Google this at work.}%
\end{document}
这个想法是用作\card
主要的卡片设置宏,并带有一个可选参数,规定背面应打印的内容。如果背面不是以三张为一组提供,可能仍需要进行一些工作来重新排序。但是,对于你的情况 - 所有卡片都有相同的背面 - 这应该不是问题。
列表收集和处理可通过以下方式实现etoolbox
。
原解决方案:
我将使用以下定义\cardback
:
\newcommand\cardback[1]{%
\begingroup\fboxsep=10pt%
\fbox{\begin{minipage}[t][\cardheight][t]{\dimexpr\cardwidth-2\fboxsep-2\fboxrule\relax}%
\raggedright%
%\rlap{\raisebox{\dimexpr-\height}[0pt][0pt]{% Underlay image background
\includegraphics[width=\linewidth,height=\cardheight]{#1}%
%}%
\end{minipage}}%
\hspace{1pt}%
\endgroup}%
它会插入一个图像,使其完全覆盖文本所在的区域。如果您还想用文本覆盖它,请取消注释该\rlap{\raisebox...}
部分。然后您可以添加任何您想要的内容,因为图像将放置在文本下方。当然,这需要graphicx
。您可以通过宏和循环以您想要的方式对其进行扩展,类似于您对 所做的那样\cards
。
\documentclass{article}
\usepackage[utf8]{inputenc} %Needed for input
\usepackage{venturis} %CM does not look right at this size
\usepackage[T1]{fontenc} %Needed for output
\usepackage[margin=0.4cm]{geometry} %The layout gets screwed up if I don't include this.
\usepackage{graphicx}% For images
\newlength\cardheight
\newlength\cardwidth
\setlength\cardheight{0.3\textheight}
\setlength\cardwidth{0.3\textwidth}
\setlength{\fboxsep}{20pt}
\newcommand\card[2]{%
\begingroup\fboxsep=10pt%
\fbox{\begin{minipage}[t][\cardheight][t]{\dimexpr\cardwidth-2\fboxsep-2\fboxrule\relax}%
\raggedright%
\vspace{0.5 \baselineskip}%
\LARGE #1%
\vfill%
\noindent \normalsize #2%
\end{minipage}}%
\hspace{1pt}%
\endgroup}%
\newcommand\cardback[1]{%
\begingroup\fboxsep=10pt%
\fbox{\begin{minipage}[t][\cardheight][t]{\dimexpr\cardwidth-2\fboxsep-2\fboxrule\relax}%
\raggedright%
%\rlap{\raisebox{\dimexpr-\height}[0pt][0pt]{% Underlay image background
\includegraphics[width=\linewidth,height=\cardheight]{#1}%
%}%
\end{minipage}}%
\hspace{1pt}%
\endgroup}%
\makeatletter%
\newcommand{\cards}[2]{%
\@for\@c:=#1\do{%
\card{\@c}{#2}%
}%
}%
\makeatother%
\newcommand{\blank}{\hrulefill}
\pagestyle{empty}
\begin{document}
\centering
\cards{%Basic set
A big hoopla about nothing,%
A wheelchair death race%
}{Cards Against Humanity: Googling this is probably a bad idea}%
\cards{%The Canadian Expansion
Burning down the White House,%
Terry Fox's prosthetic leg,%
{The Offical Languages Act \\\vspace{\baselineskip} \noindent La Loi sur les langues officielles.},%To show you some of my cards are a bit more complex
The Front de Libération du Québec,%
Poutine,%
Killing a Moose with your bare hands%
}{Cards Against Humanity:\\ The Canadian Expansion. No really, don't google this at work.}%
\cards{%The Second Expansion
A piñata full of scorpions%
}%
{Cards Against Humanity:\\The Second Expansion. This if a card game for horrible people.}%
\clearpage
\cardback{example-image-a}%
\cardback{example-image-b}%
\cardback{example-image-c}%
\cardback{example-image-c}%
\cardback{example-image-a}%
\cardback{example-image-b}%
\cardback{example-image-b}%
\cardback{example-image-c}%
\cardback{example-image-a}%
\end{document}
答案2
我不确定文档类是否flashcards
能满足您的需求,但会自动制作正面和/或背面的页面,并且每张卡片都是一个简单的环境,如下所示:
\begin{flashcard}
{front text}
back text
\end{flashcard}
利用该headings
样式,您还可以在\cardfrontfoot{text}
命令中包含一个运行页脚,以及为每张卡片设置一个标题作为其环境的可选参数,如下面的代码所示。
要以 3 x 3 布局设置肖像卡,请将文件复制到与文档同一目录中的avery5371.cfg
另一个文件(如),然后根据需要进行编辑修改,例如:mycard.cfg
\newcommand{\cardpapermode}{portrait}
\newcommand{\cardpaper}{a4paper}
\newcommand{\cardrows}{3}
\newcommand{\cardcolumns}{3}
\setlength{\cardheight}{9cm}
\setlength{\cardwidth}{6cm}
\setlength{\topoffset}{1cm}
\setlength{\oddoffset}{1.5cm}
\setlength{\evenoffset}{1.5cm}
不要将这些命令复制并粘贴到主文档的前言部分!它们必须位于配置文件中,并作为文档类中的选项加载。即:
\documentclass[mycard, ...]{flashcards}
完整示例:
\documentclass[mycard,frame]{flashcards}
% Note: mycard.cfg must be in the path
% Print only fronts = option "fronts"
% Print only backs = option "backs"
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
% Card style
\cardfrontheadstyle[\ttfamily]{left}
\cardfrontfootstyle[\small\itshape]{left}
\cardfrontstyle{headings}
% Macros for simplify 3 back sides. Change as you want
\newcommand\spade{{\huge $\spadesuit$}\par\bigskip Cards\\ Against\\ Humanity\par\bigskip {\huge $\spadesuit$}}
\newcommand\club{{\huge $\clubsuit$}\par\bigskip Cards\\ Against\\ Humanity\par\bigskip {\huge $\clubsuit$}}
\newcommand\heart{{\color{red}\huge $\heartsuit$}\par\bigskip Cards\\ Against\\ Humanity\par\bigskip{\color{red}\huge $\heartsuit$}}
\begin{document}
\cardfrontfoot{Googling this is probably a bad idea} % Common foot for two cards
\begin{flashcard}
[1 $\spadesuit$ ] % header (optional)
{A big hoopla about nothing} % front
\spade % back
\end{flashcard}
\begin{flashcard}
[2 $\spadesuit$]
{A wheelchair death race}
\spade
\end{flashcard}
\cardfrontfoot{The Canadian Expansion.\\ No really, don't google this at work.}
\begin{flashcard}
[1 $\clubsuit$ ]
{Burning down the White House}
\club
\end{flashcard}
\begin{flashcard}
[2 $\clubsuit$ ]
{Terry Fox's prosthetic leg}
\club
\end{flashcard}
\begin{flashcard}
[3 $\clubsuit$ ]
{The Offical Languages Act\\ \vspace{3\baselineskip} \noindent La Loi sur les langues officielles}
\club
\end{flashcard}
\begin{flashcard}
[4 $\clubsuit$ ]
{The Front de Libération du Québec\vfill}
\club
\end{flashcard}
\begin{flashcard}
[5 $\clubsuit$ ]
{Poutine}
\club
\end{flashcard}
\begin{flashcard}
[6 $\clubsuit$ ]
{Killing a Moose with your bare hands}
\club
\end{flashcard}
\cardfrontfoot{The Second Expansion. \\This if a card game for horrible people.}
\begin{flashcard}
[\textcolor{red}{1 $\heartsuit$}]
{A piñata full of scorpions}
\heart
\end{flashcard}
\end{document}