Page LayoutCustomized newsletter sections and table of contents

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
HowieCohl
Posts: 1
Joined: Thu Apr 16, 2015 3:48 pm

Customized newsletter sections and table of contents

Post by HowieCohl »

I just became an editor for a bi-monthly Newsletter and we have built XeLaTeX code to generate the newsletter. This Newsletter was previously generated using Microsoft Word. We want to maintain the organization of Newsletter as was previously done, but we want to do it with (Xe)LaTeX instead of Microsoft Word. I want to optimize our XeLaTeX code to make formatting easier.

Here is how the Newsletter is organized. There is a title banner, followed by some text and then there is a table of contents. The table of contents only lists the title of the topics as a numbered list. There are no page numbers in the table of contents. Then there is a Calendar of events which are listed and then there is a listing of all information related to the Topics. These should be numbered appropriately, and match up to the topic titles in the table of contents. Currently I am setting the numbers of the topics manually. I would like XeLaTeX to
automatically generate the numbers of the topics and also the table of contents in exactly the place I want it, near the top of the PDF file. I would like to use something like `\section` to give the information such as Title1, personA, etc., and I want XeLaTeX to generate the numbers.

Here is a sample organization of the Newsletter.

Code: Select all

O P S F N E T - Volume 22, Number 3 - May 15, 2015

...

Topics:
  1.  Title1
  2.  Title2
  3.  Title3
  4.  ...
  9.  ...
 10.  Title10

Calendar of Events:

...

Topic #1 ---- OP-SF Net 22.3 ---- May 15, 2015

From: personA
Subject: Title1

...

Topic #2 ---- OP-SF Net 22.3 ---- May 15, 2015

From: personB
Subject: Title2

...

Topic #3 ---- OP-SF Net 22.3 ---- May 15, 2015

From: personC
Subject: Title3

...
...
...

Topic #10 ---- OP-SF Net 22.3 ---- May 15, 2015

From: personC
Subject: Title10

...
Sample XeLaTeX for Newsletter:

Code: Select all

\documentclass[12pt]{article}
\usepackage{xltxtra,fontspec,xunicode}

\oddsidemargin 0.00cm
\textwidth 16.4cm
\textheight 24.0cm
\pagenumbering{arabic}
\setlength{\topmargin}{-2.5cm}

\begin{document}

\setmainfont{LucidaSansRegular.ttf}[
   BoldFont = LucidaSansDemiBold.ttf,
   ItalicFont = LucidaSansItalic.ttf ]

\noindent
\begin{center}
\vspace{1cm}
{\large O\ P - S\ F\ \ N\ E\ T - Volume 22, Number 2 - May 15, 2015}\\[0.6cm]
\end{center}

\normalsize

\begin{center}
$\{$ Contents of Newsletter header $\}$
\end{center}

\small
\noindent Topics:
\begin{enumerate}
\item Topic Title 1\\[-0.75cm]
\item Topic Title 2\\[-0.75cm]
\item Topic Title 3\\[-0.75cm]
\item Topic Title 4\\[-0.75cm]
\item Topic Title 5\\[-0.75cm]
\item Topic Title 6\\[-0.75cm]
\item Topic Title 7\\[-0.75cm]
\item Topic Title 8\\[-0.75cm]
\item Topic Title 9\\[-0.75cm]
\item Topic Title 10
\end{enumerate}

\small
\vspace{0.2cm}
\noindent {\bf Calendar of Events:}
\vspace{0.3cm}\\
$\{$ Contents of Calendar of Events $\}$

\vspace{0.4cm}

\large
\noindent Topic \#1\quad\rule[0.75mm]{15.5mm}{1.0pt}\quad OP- SF Net 22.2%
\quad\rule[0.75mm]{15.5mm}{1.0pt}\quad
March 15, 2015
\small

\vspace{0.4cm}
\noindent From: Person A1\\
Subject:~Topic Title 1\\[-0.0cm]

\noindent $\{$Contents of Topic 1$\}$

\vspace{0.4cm}

\large
\noindent Topic \#2\quad\rule[0.75mm]{15.5mm}{1.0pt}\quad OP - SF Net 22.2%
\quad\rule[0.75mm]{15.5mm}{1.0pt}\quad
March 15, 2015
\small

\vspace{0.4cm}
\noindent From: Person A2\\
Subject:~Topic Title 2\\[-0.0cm]

\noindent $\{$Contents of Topic 2$\}$


\vspace{0.4cm}

\large
\noindent Topic \#3\quad\rule[0.75mm]{15.5mm}{1.0pt}\quad OP - SF Net 22.2%
\quad\rule[0.75mm]{15.5mm}{1.0pt}\quad
March 15, 2015
\small

\noindent $\vdots$
\vspace{0.4cm}

\large
\noindent Topic \#10\quad\rule[0.75mm]{15.5mm}{1.0pt}\quad OP - SF Net 22.2%
\quad\rule[0.75mm]{15.5mm}{1.0pt}\quad
March 15, 2015
\small

\vspace{0.4cm}
\noindent From: Person A10\\
Subject:~Topic Title 10\\[-0.0cm]

\noindent $\{$Contents of Topic 10$\}$

\vspace{0.5cm}

\large
\noindent Thought of the month

\small

\vspace{0.4cm}
\noindent “Some quote.”  by Someone Else

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

Customized newsletter sections and table of contents

Post by rais »

perhaps a start would be to use your own commands, e.g., \topic for topic. If something's wrong in there, you have one cenralized point for correction, in this case, the definition of \topic.

Code: Select all

\documentclass[11pt]{article}
% to get rid of all the \small switches, I declared 11pt instead of 12pt.
\usepackage{xltxtra,fontspec,xunicode}

\usepackage{parskip}% there were way too many \noindent in the code...

% you may want to have a look at the geometry package
\oddsidemargin 0.00cm
\textwidth 16.4cm
\textheight 24.0cm
%\pagenumbering{arabic} that's article's default page numbering scheme anyway
\setlength{\topmargin}{-2.5cm}

\setmainfont{Lucida Sans}%
%\setmainfont{LucidaSansRegular.ttf}[
%   BoldFont = LucidaSansDemiBold.ttf,
%   ItalicFont = LucidaSansItalic.ttf ]
\newcommand*\OPvol{22}
\newcommand*\OPnum{2}
\newcommand*\OPdate{May 15, 2015}
\newcounter{topic}
\newcommand*\dummycontents[1][]{%
  \{Contents of
  \if\relax#1\relax
    Topic \thetopic
  \else
    #1%
  \fi
  \}\par
}
\newcommand\topic[3][]{%
  \par
  \refstepcounter{topic}%
  {\Large Topic \parbox[b]{1.9em}{\raggedleft\#\thetopic}\quad\rule[0.75mm]{15.5mm}{1.0pt}\quad OP- SF Net \OPvol.\OPnum
  \quad\rule[0.75mm]{15.5mm}{1.0pt}\quad
  \OPdate\par}%
  From: #3\par
  Subject: #2\par
  \ifx\relax#1\relax
    \addcontentsline{toc}{topic}{\protect\numberline{\thetopic}#2}%
  \else
    \addcontentsline{toc}{topic}{\protect\numberline{\thetopic}#1}%
  \fi
}%\topic[TOC entry]{topic title}{author}
\makeatletter
\newcommand*\l@topic[2]{% this is a modified copy of \l@section, taken from article.cls. The modifications were:
% (1) gobble the page number
% (2) don't use bold face
% (3) don't use additional vertical space
  \ifnum \c@tocdepth >\z@
    \addpenalty\@secpenalty
%    \addvspace{1.0em \@plus\p@}% (3)
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode% (2)
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\hfil~\par % (1)
    \endgroup
  \fi}
\makeatother
\begin{document}

%\noindent prior to center environment? What should that do?
\begin{center}
\vspace{1cm}
{\Large O\ P - S\ F\ \ N\ E\ T - Volume \OPvol, Number \OPnum\ - \OPdate\par}
%\end{center}

%\normalsize you have grouped the previous \large twice already: the braces surrounding \large and the center environment surrounding it delimit the scope of \large.
%What's left is \begin{center} following \end{center}...

%\begin{center}
\large % because of the different class option
\dummycontents[Newsletter header]
\end{center}

%\small
\tableofcontents
%\small
\vspace{0.2cm}
%\noindent {\bf Calendar of Events:} For many years now, the use of \bf, \it, \rm, and the like is discouraged
\subsection*{Calendar of Events:}
\dummycontents[Calendar of Events]

\topic{Topic Title 1}{Person A1}
\dummycontents


\topic{Topic Title 2}{Person A2}
\dummycontents


\topic[some topic]{some long topic}{S. O. Mebody}
\setcounter{topic}{9}% jumping over a few entries
\vdots

\topic{Topic Title 10}{Person A10}
\dummycontents

{\Large
Thought of the month\par}
“Some quote.”  by Someone Else

\end{document}
KR
Rainer
Post Reply