I'm relatively new to LaTeX (within a year or so). I found an attempt at a legal document file online, and have been modifying it to work as I'd like, and attempting to change the functionality around.
I'm producing something that looks like the attached photo.
Ideally, I would enter the parties like this: \party[x]{name}, where x is claimant, defendant, intervener, or any other group. Then, when it comes to formatting the legal heading, it would group them by [x], and produce something like this:
(1) NAME
(2) NAME [Claimants]
-and-
(1) NAME [Defendant]
-and-
(1) NAME [Other]
-and
(1) NAME (2) NAME [Xs]
etc... (if there were other [x]s).
I've been trying to get it such that it only adds an -and- where there is another group going below the -and-, but I'm going round in circles. I'd also like it to only add a (plural or singular) label to the final entry in a group. Without this functionality, and using two separate commands, this is what I've been using:
% Identification \NeedsTeXFormat{LaTeX2e} \ProvidesClass{skeleton} \DeclareOption{fullserif}{ \newcommand{\@fullserif}{} } \DeclareOption{detailedhead}{ \newcommand{\@detailedhead}{} } \DeclareOption*{% \PassOptionsToClass{\CurrentOption}{memoir} } \ProcessOptions\relax % Load Article Class \LoadClass{memoir} \RequirePackage{arrayjob} \RequirePackage{multido} \RequirePackage{xifthen} \RequirePackage{tramlines} \RequirePackage[calcwidth]{titlesec} \RequirePackage{luacensor-dev} \RequirePackage[british]{babel} \RequirePackage[babel=true]{microtype} \RequirePackage{setspace} \RequirePackage{multicol} \RequirePackage{dashbox} \RequirePackage{textcsc} \RequirePackage{lua-ul} \RequirePackage{soul} \sodef\an{}{.2em}{0em}{.5em} % %LAYOUT SETTINGS % \stockaiv \settrimmedsize{\stockheight}{\stockwidth}{*} \semiisopage \setlrmargins{*}{*}{1} \checkandfixthelayout \addtolength{\skip\footins}{2pc plus 5pt} \newcommand{\partysize}{\large} \newcommand{\@temp}{} % %PARAGRAPH NUMBERING % %Set up counter \newcounter{legalcount} %Create the counter \setcounter{legalcount}{0} %Set it to zero %Create paragraph command \newcommand{\pa}{\refstepcounter{legalcount}\hangfrom{\makebox[0em][r]{\thelegalcount. }}} \newcommand{\ph}{\pa \OnehalfSpacing}% \newcommand{\pd}{\pa \DoubleSpacing}% % % LEGAL HEADING AND SIGNATURE % % Set up commands for inputing case information \newcommand{\@casenumber}{} \newcommand{\casenumber}[1]{\renewcommand{\@casenumber}{#1}} \newarray\Claimants \newarray\ClDescr \newcounter{claimantcount} \setcounter{claimantcount}{0} %We have no claimants until a \claimant{} is issued. \newcommand{\@claimant}{} \newcommand{\claimant}[2][Claimant]{ \stepcounter{claimantcount} \Claimants(\value{claimantcount})={#2} \ClDescr(\value{claimantcount})={#1} \ifthenelse{\value{claimantcount}=1}{ \renewcommand{\@claimant}{#2} }{} } \newarray\Respondents \newarray\RpDescr \newcounter{respondentcount} \setcounter{respondentcount}{0} %We have no claimants until a \respondent{} is issued. \newcommand{\@respondent}{} \newcommand{\respondent}[2][Respondent]{ \stepcounter{respondentcount} \Respondents(\value{respondentcount})={#2} \RpDescr(\value{respondentcount})={#1} \ifthenelse{\value{respondentcount}=1}{ \renewcommand{\@respondent}{#2} }{} } \newcommand{\@venue}{} \newcommand{\venue}[1]{\renewcommand{\@venue}{#1}} \newcommand{\@doctype}{} \newcommand{\doctype}[1]{\renewcommand{\@doctype}{#1}} \newcommand{\@counsel}{} \newcommand{\counsel}[1]{\renewcommand{\@counsel}{#1}} \newcommand{\@chambers}{} \newcommand{\chambers}[1]{\renewcommand{\@chambers}{#1}} % Create Legal Heading \newcommand{\legalhead} { \thispagestyle{plain} \LARGE \noindent \begin{minipage}[t]{.45\linewidth} \vspace{0pt} \raggedright \noindent \underLine{\textcsc{IN THE \@venue}} \end{minipage} \hfill \begin{minipage}[t]{.45\linewidth} \vspace{0pt} \raggedleft \noindent \underLine{\textcsc{\oldstylenums{\@casenumber}}} \end{minipage} \vspace{1ex} \noindent {\LARGE\textcsc{\an{BETWEEN}}} \vspace{1ex} \LARGE \begin{center} \multido{\iClaimant=1+1}{\value{claimantcount}}{% \noindent \partysize \parbox{0.215\textwidth}{% \ifthenelse{\isundefined{\@detailedhead}} {\rule{2mm}{0pt}} {\normalsize (\iClaimant)} } \parbox{0.55\textwidth}{% \LARGE \centering {\bfseries\textcsc{\Claimants(\iClaimant)}} } \parbox{0.215\textwidth}{% \ifthenelse{\isundefined{\@detailedhead}} {\rule{2mm}{0pt}} {\raggedleft \normalsize \textcsc{[\ClDescr(\iClaimant)]}} } \newline \LARGE \newline } \vspace{-1em} \large -and- \vspace{1em} \multido{\iRespondent=1+1}{\value{respondentcount}}{% \noindent \partysize \parbox{0.215\textwidth}{% \ifthenelse{\isundefined{\@detailedhead}} {\rule{2mm}{0pt}} {\large (\iRespondent)} } \parbox{0.55\textwidth}{% \LARGE \centering {\bfseries\textcsc{\Respondents(\iRespondent)}} } \parbox{0.215\textwidth}{% \ifthenelse{\isundefined{\@detailedhead}} {\rule{2mm}{0pt}} {\raggedleft \small \textcsc{[\RpDescr(\iRespondent)]}} } \newline \LARGE \newline } \vspace{-1.6em} \tramlines{{{\LARGE\bfseries\textcsc{\@doctype}}}} \end{center} \normalsize \pagenumbering{arabic} } % Create Short Heading for Internal Docs \newcommand{\shorthead} { \thispagestyle{empty} \begin{center} \noindent \textcsc{\@claimant} v. \textcsc{\@respondent}\\ \tramlines{\@doctype} \end{center} } % Create Legal Signature \newcommand{\sign} { \begin{flushright} \textcsc{\@counsel}\\* \textsc{\@chambers}\\* \@date \end{flushright}} %Create Box and Signature \newcommand{\longsign} { \begin{multicols}{2} \noindent\dashbox[4cm]{\rule{0pt}{15mm}} \columnbreak \begin{flushright} \textcsc{\@counsel}\\* \textcsc{\@chambers}\\* \@date \end{flushright} \end{multicols} \begin{center} \begin{tabular}{@{}l@{}} \rule{4cm}{0pt}\\ \hline Signed by NAME \end{tabular} \end{center} }% % %SECTIONS % % Suppress numbered sections \setcounter{secnumdepth}{-2} \ifthenelse{\isundefined{\@fullserif}}{ %If fullserif is undefined - i.e. normal %Format Chapter \titleformat{\chapter}{\rmfamily\Large\bfseries\uppercase} {leftmargin} {0em} {}[]% \titlespacing*{\chapter}% {-2em}% {0em}% {0em}% \newcommand{\legaltitle}[1]{\begingroup \let \clearpage \relax \chapter{#1} \endgroup} %Format Section \titleformat{\section}{\rmfamily\large\bfseries} {leftmargin} {0em} {}[\titleline*{\titlerule}]% \titlespacing*{\section}% {-1.5em}% {0em}% {\parskip}% %Format SubSection \titleformat{\subsection}{\rmfamily\normalsize} {leftmargin} {0em} {}[\titleline*{\titlerule}]% \titlespacing*{\subsection}% {0em}% {0em}% {\parskip}% %Format SubSubSection \titleformat{\subsubsection}{\rmfamily\normalsize\itshape} {leftmargin} {0em} {}[]% \titlespacing*{\subsubsection}% {0em}% {0em}% {\parskip}% }{ %if \@fullsans has been defined: %Format Chapter \renewcommand\chapter{\@startsection {section}{1}{0mm}% {-\baselineskip}% {0.5\baselineskip}% {\LARGE}% } %Format Section \renewcommand\section{\@startsection {section}{1}{0mm}% {-\baselineskip}% {0.5\baselineskip}% {\Large}% } %Format SubSection \renewcommand\subsection{\@startsection {subsection}{2}{0mm}% {-\baselineskip}% {0.25\baselineskip}% {\large}% } %Format SubSubSection \renewcommand\subsubsection{\@startsection {subsubsection}{3}{0mm}% {-\baselineskip}% {0.1\baselineskip}% {\normalsize\slshape}% } } %Format Paragraph \renewcommand\paragraph{\@startsection {paragraph}{4}{0mm}% {-\baselineskip}% {0.1\baselineskip}% {\normalfont\normalsize}% } % %FORMATTING % \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase} \setmainfont{Times New Roman} %Use letters in enumerate \renewcommand{\labelenumi}{\alph{enumi}.} \renewcommand{\labelenumii}{\arabic{enumii})} %Adjust distance after paragraphs \setlength{\parskip}{1em} %Apply running headers \makepagestyle{running} \makepsmarks{running}{% \nouppercaseheads \createmark{chapter}{both}{nonumber}{}{} \createmark{section}{right}{shownumber}{}{. \space} \createplainmark{toc}{both}{\contentsname} \createplainmark{lof}{both}{\listfigurename} \createplainmark{lot}{both}{\listtablename} \createplainmark{bib}{both}{\bibname} \createplainmark{index}{both}{\indexname} \createplainmark{glossary}{both}{\glossaryname} } \makeheadrule{running}{\textwidth}{0.2pt} \makeevenhead{running}{}{}{\rightmark} \makeoddhead{running}{}{}{\rightmark} \makeevenfoot{running}{}{}{\thepage} \makeoddfoot{running}{}{}{\thepage} %Format Table of Contents \usepackage{titletoc} \contentsmargin{0pt} \titlecontents{section}[0pt] {\ssfseries\large\thecontentspage\quad} {}{}{}{} \newcommand\xquad {\hspace{1em plus.4em minus.4em}} \titlecontents*{subsection}[0pt] {\filright\small}{}{} {,~\thecontentspage} [\xquad\textbullet\xquad][] \setcounter{tocdepth}{2} %Typeset legislation \newenvironment{statquote}% {% \vspace{-2ex}\OnehalfSpacing% \begin{list}{}% {% \setlength{\topsep}{0ex}% \setlength{\partopsep}{1ex}% \setlength{\parsep}{0.5ex}% \setlength{\itemsep}{0ex}% \addtolength{\leftmargin}{1em}% \addtolength{\rightmargin}{1.5em}% }% \item[]}% {\end{list}% \vspace{1ex}% }% \newenvironment{instatquote}% {% \vspace{-4ex}% \begin{list}{}% {% \setlength{\topsep}{0.5ex}% \setlength{\partopsep}{1ex}% \setlength{\parsep}{0.5ex}% \setlength{\itemsep}{0ex}% }% \item[]}% {\end{list}% }% \newcommand*\statquotelabel[1]{} \newcommand{\stat}[2]{ \item[(#1)]#2 } \newcommand{\stathead}[2]{ \item[\textbf{#1}]\textbf{#2} } I've had a few attempts at working this out, including trying to use Expl3, but I just cannot figure it out.
Any help would be greatly appreciated!
EDIT: My attempt at making the automatic -and- function work:
% test.cls \NeedsTeXFormat{LaTeX2e} \ProvidesClass{test} \DeclareOption{fullserif}{ \newcommand{\@fullserif}{} } \DeclareOption{detailedhead}{ \newcommand{\@detailedhead}{} } \DeclareOption*{% \PassOptionsToClass{\CurrentOption}{memoir} } \ProcessOptions\relax % Required Packages \RequirePackage{arrayjob} \RequirePackage{multido} \RequirePackage{xifthen} \RequirePackage{tramlines} \RequirePackage[calcwidth]{titlesec} \RequirePackage{luacensor-dev} \RequirePackage[british]{babel} \RequirePackage[babel=true]{microtype} \RequirePackage{setspace} \RequirePackage{multicol} \RequirePackage{dashbox} \RequirePackage{textcsc} \RequirePackage{lua-ul} \RequirePackage{soul} \sodef\an{}{.2em}{0em}{.5em} % Layout Settings \stockaiv \settrimmedsize{\stockheight}{\stockwidth}{*} \semiisopage \setlrmargins{*}{*}{1} \checkandfixthelayout \addtolength{\skip\footins}{2pc plus 5pt} \newcommand{\partysize}{\large} \newcommand{\@temp}{} \RequirePackage{expl3} \ExplSyntaxOn \seq_new:N \l_parties_claimant_seq \seq_new:N \l_parties_defendant_seq \seq_new:N \l_parties_intervenor_seq \seq_new:N \l_parties_other_seq \NewDocumentCommand{\party}{mm} { \str_case:nn { #1 } { {claimant} { \seq_put_right:Nn \l_parties_claimant_seq { #2 } } {defendant} { \seq_put_right:Nn \l_parties_defendant_seq { #2 } } {intervenor} { \seq_put_right:Nn \l_parties_intervenor_seq { #2 } } {other} { \seq_put_right:Nn \l_parties_other_seq { #2 } } } } \NewDocumentCommand{\legalhead}{} { \thispagestyle{plain} \LARGE \noindent \begin{minipage}[t]{.45\linewidth} \vspace{0pt} \raggedright \noindent \underLine{\textcsc{IN THE \@venue}} \end{minipage} \hfill \begin{minipage}[t]{.45\linewidth} \vspace{0pt} \raggedleft \noindent \underLine{\textcsc{\oldstylenums{\@casenumber}}} \end{minipage} \vspace{1ex} \noindent {\LARGE\textcsc{\an{BETWEEN}}} \vspace{1ex} \LARGE \begin{center} \__print_parties:nn {claimant} {Claimants} \__print_and:n {defendant} \__print_parties:nn {defendant} {Defendants} \__print_and:n {intervenor} \__print_parties:nn {intervenor} {Intervenors} \__print_and:n {other} \__print_parties:nn {other} {Others} \end{center} \normalsize \pagenumbering{arabic} } \cs_new_protected:Npn \__print_parties:nn #1 #2 { \seq_if_empty:NTF \l_parties_#1_seq {} { \seq_map_indexed:Nn \l_parties_#1_seq { \__print_party:nn { ##2 } { ##1 } } \__print_label:n { #2 } } } \cs_new_protected:Npn \__print_party:nn #1 #2 { \noindent \partysize \parbox{0.215\textwidth} { \ifthenelse{\isundefined{\@detailedhead}} {\rule{2mm}{0pt}} {\normalsize (#2)} } \parbox{0.55\textwidth} { \LARGE \centering {\bfseries\textcsc{#1}} } \parbox{0.215\textwidth} { \ifthenelse{\isundefined{\@detailedhead}} {\rule{2mm}{0pt}} {} } \newline \LARGE \newline } \cs_new_protected:Npn \__print_label:n #1 { \hfill \textsc{[#1]} } \cs_new_protected:Npn \__print_and:n #1 { \seq_if_empty:NTF \l_parties_#1_seq {} { \vspace{-1em} \large -and- \vspace{1em} } } \ExplSyntaxOff \newcommand{\@venue}{} \newcommand{\venue}[1]{\renewcommand{\@venue}{#1}} \newcommand{\@doctype}{} % \newcommand{\doctype}[1]{\renewcommand{\@doctype}{#1}} % Removed as it's not defined \newcommand{\@counsel}{} \newcommand{\counsel}[1]{\renewcommand{\@counsel}{#1}} \newcommand{\@chambers}{} \newcommand{\chambers}[1]{\renewcommand{\@chambers}{#1}} But this doesn't work with this input:
\documentclass{test} \begin{document} \venue{HCoJ-CD} \casenumber{123456} \doctype{Skeleton Argument...} \party{claimant}{Random A} \party{claimant}{Random B} \party{defendant}{Random C} \party{defendant}{Random D} \party{other}{Random E} \legalhead \end{document} 