我需要制作俱乐部花名册。我打算使用 {labels} 包,它允许读取外部文件并很好地格式化花名册页面的标签。我已经把一切都搞定了。问题:我必须在每一页或奇数页上放置一个标题。\usepackage{labels} 和 \usepackage{fancyhdr} 似乎不能一起工作,即使标签包文档建议使用它来做我想要的事情。只需将这两个包放入序言中就会破坏标题。看来标签包总是会覆盖标题。
此外,我还研究了使用表格环境构建标签。有可能,但表格环境中缺少换行符,这导致我不得不到处寻找,然后重新发明轮子。如果这还不够清楚,我可以提供一个 MWE,但它不是最短的。还有一个名为 EnvLab 的旧包。我不知道它是否会制作带有标题的标签页。
要求:
- 纸张尺寸必须为 5.5 x 8 英寸,双面打印,用于制作小册子。实际复印纸为 5.5 x 8 预裁纸。打印机将双面打印
- 除标题页外,每个右侧页面都会有一个页眉,其中包含徽标和俱乐部名称(就像页面顶部的横幅一样)
- 除标题页外的每一页都会有页码。
- 它将有一个标题页
- 官员页面 - 8 个姓名,附带电子邮件地址。
- 会员页面很多,每页 6 个,分为 2 列 - 与邮寄标签完全相同。每对会员分配约 13 行(行)。
- 按船名排序的列表 - 这些不是标签
- 按 Marina 名称排序的列表 - 这些不是标签
\documentclass{article}
\usepackage{parskip}
\usepackage{tgtermes} %The TeX Gyre Termes family of fonts is based on the Nimbus Roman family, but heavily extended. Math support is available in OpenType format.
\usepackage[T1]{fontenc} %for unicode
\usepackage[utf8]{inputenc}
\usepackage[paperwidth=5.5in,paperheight=8in, top=25mm
, left=20mm]{geometry} %for paper size
\usepackage{xcolor}
\usepackage{graphicx}
\definecolor{navy}{RGB}{0,0,150}
\definecolor{green}{RGB}{0, 150, 0}
\usepackage[colorlinks=false,
allbordercolors={0 0 1},
pdfborderstyle={/S/U/W 1}]{hyperref}
\usepackage{fancyhdr}
\setlength{\headheight}{33pt}
\pagestyle{fancy}
\fancyhf{} %clear header and footer
\chead{\scalebox{1.5}{ \raisebox{2.5mm}{\color{navy}{Great Sailing Association}}}}
\lhead{\includegraphics[width=1.5cm]{Swedish_Flag.png}}
\rhead{\scalebox{1.5}{ \raisebox{2.5mm}{\color{navy}{\thepage}}}}
\usepackage{setspace} %needed for double spacing officers
\renewcommand{\familydefault}{\sfdefault} %sans serif
\usepackage{helvet}
%DISABLE THIS PACKAGE TO SEE ALL ELSE WORKING
\usepackage[newdimens]{labels}
%\LabelGridtrue
\LabelCols=2%Number of columns of labels per page
\LabelRows=3%Number of rows of labels per page
\LeftPageMargin=.5in% Gutter
\RightPageMargin=.5in%
\InterLabelRow=0.1in% Gap between rows of labels
\TopPageMargin=25mm%
\BottomPageMargin=5mm%
\InterLabelColumn=5mm% Gap between columns of labels
%%%%%%%%%%%%%%%%%%%%%% Start of the document %%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{titlepage}
\thispagestyle{empty}
\setcounter{page}{0}
\begin{center}
\rmfamily
\vspace*{4\baselineskip}
\includegraphics[width=4cm]{Swedish_Flag.png}
\vspace{2\baselineskip}
\scalebox{8}{\color{navy}{GSA}}
\vspace*{1\baselineskip}
\scalebox{8}{\color{navy}{Roster}}
\vspace*{\fill}
{\scalebox{2}{\color{navy}{May 2021}}}
\end{center}
\end{titlepage}
%\vspace*{4\baselineskip}
\begin{center}
\textbf{\textcolor{blue}{\LARGE{}Officers}}
\vspace*{1\baselineskip}
\end{center}
{\Large{}Commodore: \href{http://[email protected]}{\textcolor{navy}{Adam One}}}
\vspace*{1\baselineskip}
{\Large{}Past Commodore: \href{http://[email protected]}{\textcolor{navy}{Adam Two}}}
\vspace*{1\baselineskip}
{\Large{}Vice Commodore: \href{http://[email protected]}{\textcolor{navy}{Robert Three}}}
\vspace*{1\baselineskip}
{\Large{}Rear Commodore: \href{http://[email protected]}{\textcolor{navy}{Tony Four}}}
\vspace*{1\baselineskip}
{\Large{}Treasurer: \href{http://[email protected]}{\textcolor{navy}{Billy Jack}}}
\vspace*{1\baselineskip}
{\Large{}Portsmouth Captain: \href{http://[email protected]}{\textcolor{navy}{David Six}}}
\vspace*{1\baselineskip}
{\Large{}PHRF Captain: \href{http://[email protected]}{\textcolor{navy}{Sarah Seven}}}
\vspace*{1\baselineskip}
{\Large{}Secretary: \href{http://[email protected]}{\textcolor{navy}{Laura Eight}}}
\vspace*{1\baselineskip}
{\Large{}Senior Member: \href{http://[email protected]}{\textcolor{navy}{Evelyn Nine}}}
\pagebreak
{\Large{}Just another page}
\vspace*{1\baselineskip}
{\Large{}With Two Lines. It should have a header too. But doesn't}
\pagebreak
\begin{labels}
Ann P Adams
1200 Pine Heights Ave.
Metropolis, TX 21229
Cell: 410-111-3990c
[email protected]
Joined: 1990
Richard \& Sandra Allen III
2120 Tred Avon Rd.
Metropolis, TX 21221
Home: 410-111-3069
Cell: 410-111-6407c
[email protected]
Marina: Home
Boat: DRAGON LADY
Type: Vagabond 47
Joined: 2006
Matthew \& Mary Beaty
13406 Blythenia Rd.
Phoenix, MD 21131
Home: 443-111-6474
Work: 443-111-6474
Cell: 443-111-6474c
[email protected]
Joined: 1986
Chris Bero
5020 Shetland Ct
Metropolis, PA 17050
Home: 717-111-1338
Work: 717-111-1929 x247
Cell: 717-111-0458
[email protected]
[email protected]
Marina: Bowleys Marina
Boat: SEOUL MATES
Type: Hunter 36
Joined: 2015
Barry Bilson
3617 Bay Drive
Metropolis, TX 21220
Home: 410-111-0207
Cell: 410-111-1568c
[email protected]
Marina: Bowleys Marina
Boat: EXPRESSWAVE
Type: Express 30
Joined: 1982
Gregory \& Donna Bincarowsky
2751 Druck Valley Rd.
Metropolis, PA 17406
Work: 717-111-2234
Cell: 717-111-8681c
[email protected]
Marina: Magothy River
Boat: CHAMPAGNE
Type: Catalina 34
Joined: 2004
Joe \& Elaine Borrison
4 Lantern Circle
Parkton, MD 21120
Home: 410-111-9449
Cell: 410-111-5151
[email protected]
Marina: Private Mooring
Boat: TIPSY TURTLE
Type: IC24
Joined: 2017
Brian Bashears
2122 Rosalie Ave
Metropolis, MD 21221
Home: 410-111-5356
Cell: 410-111-5356
[email protected]
Marina: Home
Joined: 2020
Tom \& Alma Brown
122 Union Rd.
Metropolis, PA 19320
Home: 610-111-1372
Cell: 484-111-4825c
[email protected]
Marina: Bowleys Marina
Boat: ORIONS CHILD
Type: Hunter 33.5
Joined: 2001
Tom \& Joann Calvert
115 Shetland Hills Dr.
Metropolis, TX 21093
Home: 410-111-9275
Work: 410-111-4788
Cell: 443-111-5360
[email protected]
Marina: Windy Hill Marina
Boat: STILL a GORILLA
Type: S-2 9.1
Joined: 1977
Chris Carrino
112 Bridgewater Dr
Metropolis, PA 18938
Home: 202-111-3683
[email protected]
Marina: Bowleys Marina
Boat: LEAPFROG
Type: J 30
Joined: 2019
Ed \& Gloria Cilumbrello
1306 3rd Road
Metropolis, TX 21220
Home: 410-111-2181
Work: 410-111-3060
Cell: 410-111-2181c
[email protected]
Marina: Wilson Point Mens Club
Boat: CARROT
Type: Mull 46 Custom
Joined: 1985
\end{labels}
%%%%%%%%%%%%%% End of the document contents %%%%%%%%%%%%%%%%%%%
\end{document}
答案1
这是另一个选择datatool
因为您将成员列表保存在 Excel 中(并且可以将其导出为 CSV):
\documentclass{article}
\usepackage[
paperwidth=5.5in,
paperheight=8in,
margin=25mm,
left=20mm]
{geometry} %for paper size
\usepackage{xcolor,graphicx}
\definecolor{navy}{RGB}{0,0,150}
\definecolor{green}{RGB}{0, 150, 0}
\usepackage[
colorlinks=false,
allbordercolors={0 0 1},
pdfborderstyle={/S/U/W 1}]
{hyperref}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} %clear header and footer
\setlength{\headheight}{36pt}% To accommodate for the tall header (picture)
\fancyhead[L]{\includegraphics[width=1.5cm]{example-image}}
\fancyhead[C]{\scalebox{1.5}{\color{navy}{Great Sailing Association}}}
\fancyhead[R]{\scalebox{1.5}{\color{navy}{\thepage}}}
\begin{filecontents*}[overwrite]{officers.csv}
title,name,email
Commodore,Adam One,[email protected]
Past Commodore,Adam Two,[email protected]
Vice Commodore,Robert Three,[email protected]
Rear Commodore,Tony Four,[email protected]
Treasurer,Billy Jack,[email protected]
Portsmouth Captain,David Six,[email protected]
PHRF Captain,Sarah Seven,[email protected]
Secretary,Laura Eight,[email protected]
Senior Member,Evelyn Nine,[email protected]
\end{filecontents*}
\begin{filecontents*}[overwrite]{members.csv}
name,address,city,state,zipcode,home,work,mobile,emailA,emailB,marina,boat,type,joined
Adam One,123 Random Rd, Randomville,RN,12345,123-456-7890,456-789-0123,789-012-3456,[email protected],[email protected],Marina Adam,Dragon Lady,Vagabond 1,2006
Adam Two,456 Random Rd, Randomville,RN,23456,123-456-7890,456-789-0123,789-012-3456,[email protected],[email protected],Marina Adam,Dragon Sir,Vagabond 2,2007
Robert Three,789 Random Rd, Randomville,RN,34567,123-456-7890,456-789-0123,789-012-3456,[email protected],[email protected],Marina Robert,Dragon Madam,Vagabond 3,2008
Tony Four,1234 Random Rd, Randomville,RN,45678,123-456-7890,456-789-0123,789-012-3456,[email protected],[email protected],Marina Tony,Dragon Justice,Vagabond 4,2009
Billy Jack,2345 Random Rd, Randomville,RN,56789,123-456-7890,456-789-0123,789-012-3456,[email protected],,Marina Billy,Dragon Kid,Vagabond Jack,2010
David Six,3456 Random Rd, Randomville,RN,67890,123-456-7890,456-789-0123,789-012-3456,[email protected],[email protected],Marina David,Dragon Child,Vagabond 5,2011
Sarah Seven,4567 Random Rd, Randomville,RN,98765,123-456-7890,456-789-0123,789-012-3456,[email protected],[email protected],Marina Sarah,Dragon Sister,Vagabond 6,2012
Laura Eight,5678 Random Rd, Randomville,RN,87654,123-456-7890,456-789-0123,789-012-3456,[email protected],[email protected],Marina Laura,Dragon Brother,Vagabond 7,2013
Evelyn Nine,6789 Random Rd, Randomville,RN,76543,123-456-7890,456-789-0123,789-012-3456,[email protected],[email protected],Marina Evelyn,Dragon Parent,Vagabond 8,2014
\end{filecontents*}
\usepackage{datatool}
\newcommand{\printofficers}{%
\DTLloaddb{officers}{officers.csv}% Load officers database
\DTLforeach{officers}{% Process officers database
\Title=title,
\Name=name,
\Email=email%
}{%
\par\addvspace{.5\baselineskip}
\Large\Title: \href{mailto:\Email}{\color{navy}\strut\Name}\par
}
}
\newcounter{membercount}
\makeatletter
\newcommand{\setifexist}[1]{%
% https://tex.stackexchange.com/a/53091/5764
\expandafter\if\expandafter\relax\expandafter\detokenize\expandafter{#1}\relax
\expandafter\@secondoftwo
\else
\expandafter\@firstoftwo
\fi
}
\makeatother
\newcommand{\printmembers}{%
\DTLloaddb{members}{members.csv}% Load member database
\setcounter{membercount}{0}% Reset member counter
\DTLforeach{members}{%
\Name=name,
\Address=address,
\City=city,
\State=state,
\Zipcode=zipcode,
\Home=home,
\Work=work,
\Mobile=mobile,
\EmailA=emailA,
\EmailB=emailB,
\Marina=marina,
\Boat=boat,
\Type=type,
\Joined=joined%
}{%
\small
\stepcounter{membercount}% New member
\ifodd\value{membercount}
\par\addvspace{.5\baselineskip}
\fi
\makebox[.5\linewidth][l]{%
\begin{tabular}[t]{@{} l }
\Name \\
\Address \\
\City, \State~\Zipcode \\
\setifexist{\Home}{Home: \Home \\}{}
\setifexist{\Work}{Work: \Work \\}{}
\setifexist{\Mobile}{Cell: \Mobile \\}{}
\setifexist{\EmailA}{\href{mailto:\EmailA}{\EmailA} \\}{}
\setifexist{\EmailB}{\href{mailto:\EmailB}{\EmailB} \\}{}
Marina: \Marina \\
Boat: \Boat \\
Type: \Type \\
Joined: \Joined
\end{tabular}}%
}
}
\setlength{\parindent}{0pt}% Remove paragraph indent
\begin{document}
\setcounter{page}{-1}
\thispagestyle{empty}
\begin{center}
\vspace*{4\baselineskip}
\includegraphics[width=4cm]{example-image}
\vspace{2\baselineskip}
\scalebox{8}{\color{navy}{GSA}}
\vspace*{\baselineskip}
\scalebox{8}{\color{navy}{Roster}}
\vspace*{\fill}
{\scalebox{2}{\color{navy}{May 2021}}}
\end{center}
\clearpage
\begin{center}
\bfseries\LARGE\color{blue}Officers
\end{center}
\addvspace{\baselineskip}
\printofficers
\clearpage
{\Large Just another page}
\vspace*{\baselineskip}
{\Large With Two Lines.}
\clearpage
\printmembers
\end{document}
我已在示例中逐字逐句地写了 CSV 和officers.csv
,members.csv
但您会将它们存储在其他地方,因此不需要该代码。
答案2
您可以将包和组合起来multicol
,以生成成员列表。要编译文档,您需要 4 个 csv 文件,分别名为、、... 每个 csv 文件包含一名成员的所有信息,文件按您希望相应条目在小册子中出现的顺序进行编号。cvs 文件应该包含而不是和。csvsimple
pgffor
member1.csv
member2.csv
&
\&
{,}
,
在以下 MWE 中,我还尝试简化官员页面中使用的代码:
\documentclass{article}
\usepackage{parskip}
\usepackage{tgtermes} %The TeX Gyre Termes family of fonts is based on the Nimbus Roman family, but heavily extended. Math support is available in OpenType format.
\usepackage[T1]{fontenc} %for unicode
\usepackage[utf8]{inputenc}
\usepackage[paperwidth=5.5in,paperheight=8in, top=25mm
, left=20mm]{geometry} %for paper size
\usepackage{xcolor}
\usepackage{graphicx}
\definecolor{navy}{RGB}{0,0,150}
\definecolor{green}{RGB}{0, 150, 0}
\usepackage[colorlinks=false,
allbordercolors={0 0 1},
pdfborderstyle={/S/U/W 1}]{hyperref}
\usepackage{fancyhdr}
\setlength{\headheight}{36pt}
\pagestyle{fancy}
\fancyhf{} %clear header and footer
\chead{\scalebox{1.5}{ \raisebox{2.5mm}{\color{navy}{Great Sailing Association}}}}
\lhead{\includegraphics[width=1.5cm]{example-image}}
\rhead{\scalebox{1.5}{ \raisebox{2.5mm}{\color{navy}{\thepage}}}}
\usepackage{setspace} %needed for double spacing officers
\renewcommand{\familydefault}{\sfdefault} %sans serif
\usepackage{helvet}
\usepackage{multicol}
\usepackage{csvsimple}
\usepackage{pgffor}
\newcommand{\officer}[3]{{\Large{}#1: \href{#2}{\textcolor{navy}{#3}}}
\vspace*{1\baselineskip}}
\begin{document}
\begin{titlepage}
\thispagestyle{empty}
\setcounter{page}{0}
\begin{center}
\rmfamily
\vspace*{4\baselineskip}
\includegraphics[width=4cm]{example-image}
\vspace{2\baselineskip}
\scalebox{8}{\color{navy}{GSA}}
\vspace*{1\baselineskip}
\scalebox{8}{\color{navy}{Roster}}
\vspace*{\fill}
{\scalebox{2}{\color{navy}{May 2021}}}
\end{center}
\end{titlepage}
%\vspace*{4\baselineskip}
\begin{center}
\textbf{\textcolor{blue}{\LARGE{}Officers}}
\vspace*{1\baselineskip}
\end{center}
\officer{Commodore}{http://[email protected]}{Adam One}
\officer{Past Commodore}{http://[email protected]}{Adam Two}
\officer{Vice Commodore}{http://[email protected]}{Robert Three}
\pagebreak
{\Large{}Just another page}
\vspace*{1\baselineskip}
{\Large{}With Two Lines. It should have a header too. But doesn't}
\pagebreak
\begin{multicols}{2}
\setlength{\tabcolsep}{0pt}
\setlength{\arrayrulewidth}{0pt}
\foreach \ii in {1,...,4} {
\csvautotabular[respect and]{member\ii.csv}
\bigskip
}
\end{multicols}
\end{document}