3

I need to produce a club Roster. I was going to use the {labels} package, which permits reading an external file and formatting labels for the roster pages very well. I had that all worked out. Problem: I have to put a header on either every page or the odd pages. \usepackage{labels} and \usepackage{fancyhdr} do not seem to work together, even though the labels package documentation suggests using it for just what I want. Just putting those 2 packages into the preamble destroys the header. It appears that the labels package will always overwrite the header.

Also, I have investigated building my labels with a tabular environment. Possible, but the lack of newline in a tabular environment has caused me to look everywhere before reinventing the wheel. If this isn't clear enough, I can provide a MWE but it isn't the shortest one ever. There is also an older pkg called EnvLab. I couldn't tell if it would make pages of labels with a header or not.

Requirements:

  1. Paper size must be 5.5 x 8 inches, printed both sides and intended for booklet. Actual photocopy paper is 5.5 x 8 pre-cut. Printer will print both sides
  2. Every right side page except the title page will have a header containing a logo and the club name(like a banner across the top of the page)
  3. Every page except the title page will have a page number.
  4. It will have a title page
  5. Officers Page - 8 names with linked email addresses.
  6. Many pages of members, 6 per page organized in 2 columns - exactly like mailing labels. Each pair of members is alloted about 13 lines(rows).
  7. A list sorted by boat names - these are not labels
  8. A list sorted by Marina names - these are not labels
\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@gmail.com}{\textcolor{navy}{Adam One}}} \vspace*{1\baselineskip}

{\Large{}Past Commodore: \href{http://email@gmail.com}{\textcolor{navy}{Adam Two}}} \vspace*{1\baselineskip}

{\Large{}Vice Commodore: \href{http://email@gmail.com}{\textcolor{navy}{Robert Three}}} \vspace*{1\baselineskip}

{\Large{}Rear Commodore: \href{http://email@gmail.com}{\textcolor{navy}{Tony Four}}} \vspace*{1\baselineskip}

{\Large{}Treasurer: \href{http://email@gmail.com}{\textcolor{navy}{Billy Jack}}} \vspace*{1\baselineskip}

{\Large{}Portsmouth Captain: \href{http://email@gmail.com}{\textcolor{navy}{David Six}}} \vspace*{1\baselineskip}

{\Large{}PHRF Captain: \href{http://email@gmail.com}{\textcolor{navy}{Sarah Seven}}} \vspace*{1\baselineskip}

{\Large{}Secretary: \href{http://email@gmail.com}{\textcolor{navy}{Laura Eight}}} \vspace*{1\baselineskip}

{\Large{}Senior Member: \href{http://email@gmail.com}{\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 emailaddr@gmail.com Joined: 1990

Richard & Sandra Allen III 2120 Tred Avon Rd. Metropolis, TX 21221 Home: 410-111-3069 Cell: 410-111-6407c emailaddr@gmail.com 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 emailaddr@gmail.com Joined: 1986

Chris Bero 5020 Shetland Ct Metropolis, PA 17050 Home: 717-111-1338 Work: 717-111-1929 x247 Cell: 717-111-0458 emailaddr@gmail.com email2@gmail.com 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 emailaddr@gmail.com 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 emailaddr@gmail.com 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 emailaddr@gmail.com 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 emailaddr@gmail.com Marina: Home Joined: 2020

Tom & Alma Brown 122 Union Rd. Metropolis, PA 19320 Home: 610-111-1372 Cell: 484-111-4825c emailaddr@gmail.com 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 emailaddr@gmail.com 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 emailaddr@gmail.com 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 emailaddr@gmail.com Marina: Wilson Point Mens Club Boat: CARROT Type: Mull 46 Custom Joined: 1985

\end{labels}

%%%%%%%%%%%%%% End of the document contents %%%%%%%%%%%%%%%%%%% \end{document}

Narlin
  • 133
  • 5
  • A MWe as well as a sketch of the expected output would be rella helpful here. Please include them. Regarding "lack of newline in a tabular environment": there certainly are ways to achiece automtic or manual linebreaks inside of table cells. What to use in your case depends on the kind of output you want to achieve. – leandriis Mar 09 '21 at 20:05
  • OK. I will put an MWE. Do i use the Code tab in the question to add that? I haven't done this before. – Narlin Mar 09 '21 at 20:09
  • Just edit your question and add the code directly into the text. You can then highlight/select the code and click the "code" button (with "{}" on it) in order to make sure it is marked as a code sample. – leandriis Mar 09 '21 at 20:19
  • Thanks for updating your question. Since points 6, 7 and 8 all mentions somwhow sorted lists and you also previously mentioned "permits reading an external file":Do you create the sorted lists manually or are they created with the help of a different application? If so, does this application already sort the lists for you or does this application just generate an external file that you then want to use to generate your lists inside of your booklet? – leandriis Mar 09 '21 at 21:09
  • The sorted lists as well as the labels, I make in Excel, since that is where the original data is. I program in VBA and an assortment of other languages so getting the data into nearly any format is easy-ish. The {labels} package here allows reading from an external file. That will be easiest when I try to teach club members to maintain this. – Narlin Mar 09 '21 at 21:12

2 Answers2

2

Here is how you could combine the packages multicol, csvsimple and pgffor in order to produce the list of members. To compile the document, you need 4 csv files, named member1.csv, member2.csv,... Each csv file contains all the information of one member, files are numbered in the order in which you want the corresponding entries to appear in the booklet. The cvs files should contain & instead of \& and {,} intead of ,.

In the following MWE, I additionally tried to simplify the code that is used in the officers page:

\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@gmail.com}{Adam One}

\officer{Past Commodore}{http://email@gmail.com}{Adam Two}

\officer{Vice Commodore}{http://email@gmail.com}{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}

leandriis
  • 62,593
  • This looks quite promising. Give me half a day to digest it. I'll get back midday tomorrow. n. – Narlin Mar 09 '21 at 22:00
  • Even though i will use the datatool method, this works well. Only reason to go the other way is that this creates a few extra files which tend to clutter my small mind. But I up voted and learned a lot. – Narlin Mar 10 '21 at 16:28
1

Here is another option with datatool since you keep your member list in Excel (and can export it to CSV):

enter image description here

\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,adam1@cares.com Past Commodore,Adam Two,adam2@whocares.com Vice Commodore,Robert Three,robert3@whocares.com Rear Commodore,Tony Four,tony4@whocares.com Treasurer,Billy Jack,billyjack@whocares.com Portsmouth Captain,David Six,david6@whocares.com PHRF Captain,Sarah Seven,sarah7@whocares.com Secretary,Laura Eight,laura8@whocares.com Senior Member,Evelyn Nine,evelyn9@whocares.com \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,adam1@whocares.com,adamone@whocares.com,Marina Adam,Dragon Lady,Vagabond 1,2006 Adam Two,456 Random Rd, Randomville,RN,23456,123-456-7890,456-789-0123,789-012-3456,adam2@whocares.com,adamone@whocares.com,Marina Adam,Dragon Sir,Vagabond 2,2007 Robert Three,789 Random Rd, Randomville,RN,34567,123-456-7890,456-789-0123,789-012-3456,robert3@whocares.com,robertthree@whocares.com,Marina Robert,Dragon Madam,Vagabond 3,2008 Tony Four,1234 Random Rd, Randomville,RN,45678,123-456-7890,456-789-0123,789-012-3456,tony4@whocares.com,tonyfour@whocares.com,Marina Tony,Dragon Justice,Vagabond 4,2009 Billy Jack,2345 Random Rd, Randomville,RN,56789,123-456-7890,456-789-0123,789-012-3456,billyjack@whocares.com,,Marina Billy,Dragon Kid,Vagabond Jack,2010 David Six,3456 Random Rd, Randomville,RN,67890,123-456-7890,456-789-0123,789-012-3456,david6@whocares.com,davidsix@whocares.com,Marina David,Dragon Child,Vagabond 5,2011 Sarah Seven,4567 Random Rd, Randomville,RN,98765,123-456-7890,456-789-0123,789-012-3456,sarah7@whocares.com,sarahseven@whocares.com,Marina Sarah,Dragon Sister,Vagabond 6,2012 Laura Eight,5678 Random Rd, Randomville,RN,87654,123-456-7890,456-789-0123,789-012-3456,laura8@whocares.com,lauraeight@whocares.com,Marina Laura,Dragon Brother,Vagabond 7,2013 Evelyn Nine,6789 Random Rd, Randomville,RN,76543,123-456-7890,456-789-0123,789-012-3456,evelyn9@whocares.com,evelynnine@whocares.com,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}

I've written the CSV's verbatim in my example as officers.csv and members.csv, but you will have these stored elsewhere, so won't need that code.

Werner
  • 603,163
  • Got it. I'll try this too. I had previously looked at datatool before posting this question and that is where i was going next. – Narlin Mar 09 '21 at 22:17
  • This worked well. Just prep the data to remove special characters and replace with &, #, _ etc. – Narlin Mar 10 '21 at 16:26
  • @Narlin: There are options within datatool to accommodate for special characters so you don't have to do that. Read about \DTLloadrawdb within the datatool documentation. – Werner Mar 10 '21 at 16:52
  • So yeah. That was a 2 times by 3 letter trivial change to the tex file which saves about 10 lines of VBA code, plus not having to explain it to anyone. cool! Just change \DTLloaddb to \DTLloadrawdb in both uses. – Narlin Mar 10 '21 at 18:11