2

I am trying to create a class file to format a particular kind of index required for certain legal documents in the United States. I have come up with two different approaches, but neither allows me to get exactly what I want.

The goal is to have a citation, a dot fill, and then a list of page numbers and ranges. Usually the citation is short and there are only a few pages, so I can use:

Example Citation \dotfill 1, 3, 6--7\\

In that simple scenario, the dots begin just after the citation and continue until right before the page numbers, which is what I want.

The complexity arises where either the citation or the list of pages/ranges is too long to fit on one line. When the citation is too long, I want the dots to begin at the end of the second line of the citation. The first way I have come up with to do this is the tabularx environment. For instance:

\begin{tabularx}{\textwidth}{X r}
\textsc{TabularX (ok)}&\\
Example Citation \dotfill\rlap{\kern2\tabcolsep}& 1, 3, 6--7\\
Here is a very long citation that continues on for a while and therefore needs to have a line break  \dotfill\rlap{\kern2\tabcolsep}& 5, 14
\end{tabularx}
~\\

\noindent
\begin{tabularx}{\textwidth}{X r}
\textsc{TabularX (bad)}&\\
Example Citation \dotfill\rlap{\kern2\tabcolsep}& 1, 3, 6--7\\
Here is a very long citation that continues on for a while and therefore needs to have a line break  \dotfill\rlap{\kern2\tabcolsep}& 5, 14\\
And a short one with lots of pages \dotfill\rlap{\kern2\tabcolsep}& \parbox[t]{0.25\linewidth}{2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30}
\end{tabularx}

But this has two big problems. First, the page numbers start at the top of the cell, in line with the first line of the citation, rather than at the same vertical position as the dot fill (in line with the last line from the citation). Second, the column containing the page numbers will resize to fit the longest list of page numbers for any citation. For every citation that appears on fewer pages, the dot fill will stop far short of the first page reference (assuming the pages are \raggedleft aligned). I can use parboxes or fixed column widths to get linebreaks in the page numbers, but if there are only one or two pages for a citation, I cannot get the dotfill to continue until the first page number. There is an empty white space.

To get around those contstraints, I tried a second approach. This time, I dispensed with the tabular and put the citations and pages/ranges in varwidth environments.

\begin{varwidth}{0.7\textwidth}
Example Citation
\end{varwidth}
\dotfill
\begin{varwidth}{0.2\textwidth}
\raggedleft 1, 3, 6--7
\end{varwidth}
\begin{varwidth}{0.7\textwidth}
Here is a very long citation that continues on for a while and therefore needs to have a line break
\end{varwidth}
\dotfill
\begin{varwidth}{0.2\textwidth}
\raggedleft 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30\phantom{,}
\end{varwidth}

This solves the problem of leaving white space before the first page number for citations with fewer pages. But the first page number is now aligned at the top of a varwidth box rather than with the last line of the multi-line citation, and the dot leader is no longer aligned with the last line of the multi-line citation either.

So that leads me to my question. Is there some way to align the dot leader and top of the second varwidth environment (with the page numbers\ranges) with the last line of the first varwidth environment (with the citation)?

See results of each code block above

1

2 Answers 2

1

Here is my attempt at a visual mock-up, using tabularray package just as a drawing tool:

tblr

Is the arrangement what you are describing? (ignore the colours etc)

MWE

\documentclass{article}
\usepackage{xcolor}
\usepackage{tabularray}
\pagecolor{black!2!blue!3}



\begin{document}



    \begin{tblr}
        {
      width     = {\textwidth},
      colspec   = {X[l]X[c]X[r] },
      rowspec   = {X[t]X[b]X[b] },
      hlines = {2pt, solid, white},
%      vlines,
      vline{1,4} = {2pt, solid, white},
%      vline{2,3} = {1pt, solid, blue!15},
%      vline{2,3} = {1}{solid, green!65},
      columns = {bg=blue!15,fg=black},
      column{1}     = {wd=0.7\textwidth,rightsep=0pt},
      column{2}     = {wd=0pt,leftsep=0pt,rightsep=0pt},
      column{3}     = {font=\sffamily,leftsep=-2pt},
      row{1}    = {font=\bfseries\rmfamily, bg=green!40},
%      Vborders{2} = {rightspace=10pt},
    }
       C & &  pp  \\
       Example Citation
       \space\dotfill
       & \dotfill
        & \dotfill\space
                     1, 3, 6--7 
        \\
       Here is a very long citation that continues on for a while and therefore needs to have a line break
       \space\dotfill 
        & \dotfill
        & \dotfill\space
        2, 4, 6
        \\
        And a short one with lots of pages
               \space\dotfill
        & \dotfill
        & \dotfill\space
                         2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30
        \\
        \end{tblr}


\end{document}

Edit

Based on the comment, here is a workable example:

toa

MWE

\documentclass{article}
\usepackage{tabularray}

\begin{document}

    \begin{tblr}
        {
      width     = {\textwidth},
      colspec   = {X[l,b]X[r]},
%      hlines,
%      vlines,
      column{1}     = {wd=0.7\textwidth,rightsep=0pt},
      column{2}     = {leftsep=-2pt},
    }
       Example Citation
       \space\dotfill
        & \dotfill\space
                     1, 3, 6--7 
        \\
       Here is a very long citation that continues on for a while and therefore needs to have a line break
       \space\dotfill 
        & \dotfill\space
        2, 4, 6
        \\
        And a short one with lots of pages
               \space\dotfill
        & \dotfill\space
                         2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30
        \\
       x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
       \space\dotfill 
        & \dotfill\space
        2, 4, 6
        \\
       x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
       \space\dotfill 
        & \dotfill\space
             2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24
        \\
        \end{tblr}


\end{document}
2
  • Yes. That is what I’m trying to accomplish.
    – bbernicker
    May 31, 2023 at 11:51
  • This is fantastic. Thank you Cicada.
    – bbernicker
    Jun 3, 2023 at 2:25
0

The indexing and bibliographical machinery handles such things.

Is this the type of thing you are after? If yes, I can tidy up the rough coding and do a mini-tutorial.

ToA

Code in a standalone file, for reference:

%Toolchain:
%(pdf/xe/lua)latex with shell escape
%biber
%latex
%splitindex -s plainindexstyle.ist
%latex
%latex

\begin{filecontents*}[overwrite]{\jobname.bib}
@misc{tcpr,  %misc: just for demo
  title = {TCPR},
  pagination = {rule}, %bibstring to apply if postnote is digits
    }
@misc{auth1, 
  title = {A v B},
  author = {{4 LR 456}},
    }
@misc{auth2c, 
  title = {The Dog Co. v. The Cat Co.},
  author = {{4 LR 458}},
    }
@misc{auth3c, 
  title = {U.S. v. U.S.},
  author = {{102 U.S.X.C. 123}},
    }

@misc{long, 
  title = {Here is a very long citation that continues on for a while and therefore needs to have a line break},
  author = {{Case Reference}},
    }   

@misc{short, 
  title = {And a short one with lots of pages},
  author = {{Case Ref Short}},
    }   


\end{filecontents*}

%style file for index
\begin{filecontents*}{plainindexstyle.ist}
delim_0 "\\space\\dotfill\\space "
delim_1 "\\space\\dotfill\\space "
delim_2 "\\space\\dotfill\\space "
delim_n ", "
delim_r "--"
delim_t ""
encap_prefix "\\"
encap_infix "{"
encap_suffix "}"

\end{filecontents*}


\begin{filecontents*}{splitindextoa.yaml}
!config
# for Arara
identifier: splitindex
name: splitindex
authors:
-  cicada
commands:
- name: splitindex
  command: >
    @{
        base = getBasename(reference.getName());
        optiona = [ '--' ];
        optionb = [ '-s' ];
        optionc = [ '-c' ];
        return getCommand('splitindex', base, optiona, optionb, style, optionc);
    }
arguments:
#- identifier: style
#  flag: "@{ [ '-s', parameters.style ] }"
- identifier: style
  flag: >
    @{
      parameters.style
    }
\end{filecontents*}


\begin{filecontents*}{splitindexdefault.yaml}
!config
# for Arara
identifier: splitindexdefault
name: splitindexdefault
authors:
-  cicada
commands:
- name: splitindexdefault
  command: >
    @{
        base = getBasename(reference.getName());
        optiona = [ '-m' ];
        optionc = [ '' ];
        return getCommand('splitindex', base, optiona, optionc);
    }
\end{filecontents*}



\documentclass{article}
\newcommand\rulesep{\rule{0.4\textwidth}{.4pt}}
%------------------

\title{Creating a Table of Rules}
\author{}
\date{}


\usepackage[splitindex,noautomatic,nonewpage]{imakeidx}

\newcommand\abibname{authortitle}
\newcommand\abibstyle{style=\abibname}
\usepackage[
    \abibstyle , 
    indexing=cite,
    citetracker=true,
    ibidtracker=false,
    pagetracker=true,
%   idemtracker=true,
%   opcittracker=true,
%   loccittracker=true,
%   autocite=footnote,
%   datezeros=true,
        ]{biblatex}

\addbibresource{\jobname.bib}
        
\NewBibliographyString{atparagraph,rule}        
\DefineBibliographyStrings{english}{%
atparagraph = {at para},
rule = {r},
}

\DeclareCiteCommand{\toacite}%
  {\usebibmacro{prenote}}
  {\printfield{title}%
    \setunit{\addcomma\space}%
    \printnames{author}%
   }
  {}%\multicitedelim
  {\usebibmacro{postnote}}

%=================
%indexing


\newcommand\pagerefindexnote{\noindent\small\mdseries $\to$ References are to page numbers.}


\makeindex

\makeindex[name=rulesa,title=Table of TCP Rules,columns=3,columnseprule,intoc]
\makeindex[name=cases,title={\normalsize Cases},columns=1]
\makeindex[name=rules,title={\normalsize Rules},columns=1]




\usepackage[
                final=true,
                bookmarks,
            colorlinks=true,        
            allcolors = black,  
            citecolor=blue, 
            hyperindex=false,       
]{hyperref}



% variations instead of having \cite...\index... all the time
\newcommand{\icite}[1]{\cite[#1]{tcpr}\index[rulesa]{r~#1}}

\newcommand{\iicite}[2]{\cite[#1]{tcpr}\index[rulesa]{r~#2@r~#1}}

\newcommand{\iiicite}[3]{\cite[#1]{tcpr}\index[rulesa]{r~#3@r~#2{#1}}}

\newcommand{\ivcite}[4]{\cite[#1]{tcpr}\index[rulesa]{r~#3@r~#2{#1}|#4}}


\newcommand{\vcite}[2]{\cite[#1]{tcpr}\index[rulesa]{#2}}


%some wrapper commands for convenience
%%\imki@wrindexentry{names}{Charles}{26} - this is an imakeidx macro
\makeatletter
\newcommand{\addindexitem}[3]{%
\imki@wrindexentry{#1}{#2}{#3}}
\makeatother

\newcommand{\textformat}[1]{\textsf{\textbf{#1}}}

\newcommand\yq{\begin{quotation}}
\newcommand\yqq{\end{quotation}}

\newcommand\yc{\begin{center}}
\newcommand\ycc{\end{center}}

\newcommand\yi{\begin{itemize}}
\newcommand\yii{\end{itemize}}

\newcommand\yis{\item[\space]}

\newcommand\zzz[2]{\cite[#1]{tcpr}\index[rules]{r #2@\citetitle[#1]{tcpr}}}
%1=rule2=sortkey

%------------------
\begin{document}

\maketitle
\newpage
\tableofcontents
\newpage
\index{p} %seems general index is expected/assumed??
%\printindex

\indexprologue{\pagerefindexnote}

%\addindexitem{cases}{     @\textit{Case}|textit}{Page(s)}
%\addindexitem{rules}{     @\textit{Rule}|textit}{Page(s)}

\printindex[rulesa]

\newpage

Index the citations.

Use multiple indices, one for each category of authority.


\yc
\bfseries
TABLE OF AUTHORITIES
\ycc

\hfill\textbf{Page(s)}

\printindex[cases]

\printindex[rules]


\newpage
\section{Text}

\cite[4]{tcpr}\index[rulesa]{4}

xxx

\section{More Text}
xxx
\newpage
\cite[4]{tcpr}\index[rulesa]{4}

\cite[123]{tcpr}\index[rulesa]{123}

\iicite{5}{006}, \iicite{15}{015}, \iicite{52}{052}, \iicite{502}{502}, \iicite{12}{012}.

\cite[4556]{tcpr}\index[rulesa]{4556}

\iicite{53}{053}


\iiicite{14}{\textit}{014}

\iiicite{16}{\textbf}{016}


\iiicite{18}{}{018}{textbf}

\vcite{19}{r~019@r~19|textformat}

\vcite{19(a)}{r~019a@r~19!(a)} versus \vcite{r~19(a)}{r~019a@r~19!(a)}


\vcite{55(b)}{r~055b@r~55(b)|see{52(a)}}

\vcite{55(c)}{r~055c@r~55(c)!see{52(a)}}


\vcite{52(a)}{r~052a@r~52(a)}



\newpage

\vcite{52(a)}{r~052a@r~52(a)}

$\to$ \textbackslash index\{indexentry\}

An \verb.indexentry. is formatted as:

\yq
\yc
a@b|c
\ycc
where
\yi
\yis a = sortkey
\yis b = index display key(s), up to three levels
\yi
\item[·] level1!level2!level3
\yii
\yis c = page number format command name (without the backslash)
\yi
\item[·] can be \verb,see{...},
\yii
\yii
\yc
e.g., 052@52|textbf
\ycc

Sort the item as 052, print 52, and make the page number bold.

\textbf{References}: Do \verb.texdoc makeindex. to bring up both \verb,makeindex.pdf, and \verb,ind.pdf, manuals.
\yqq

\cite[457]{auth1}\index[cases]{avb@\citetitle{auth1}, \citeauthor[457]{auth1}}


\cite[45]{tcpr}\index[rules]{r 045@\citetitle[45]{tcpr}}
\zzz{123}{123}
\zzz{200}{200}
\cite{auth2c}\index[cases]{TheDogCo@\citetitle{auth2c}, \citeauthor{auth2c}}
\toacite{short}\index[cases]{Anda@\toacite{short}}

\newpage
\cite{auth2c}\index[cases]{TheDogCo@\citetitle{auth2c}, \citeauthor{auth2c}}
\cite{auth2c}\index[cases]{TheDogCo@\citetitle{auth2c}, \citeauthor{auth2c}}
\cite{auth3c}\index[cases]{us@\citetitle{auth3c}, \citeauthor{auth3c}}
\zzz{123}{123}
\zzz{200}{200}
\zzz{201}{201}

\zzz{r 212(a)}{212(a)}
versus
\cite[r 212(a)]{tcpr}\index[rules]{r 212(a)@\citetitle [r 212(a)]{tcpr}}%note the space


\newpage

\cite{auth3c}\index[cases]{us@\citetitle{auth3c}, \citeauthor{auth3c}}
\zzz{123}{123}

\newpage
\cite{auth3c}\index[cases]{us@\citetitle{auth3c}, \citeauthor{auth3c}}
\zzz{85}{085}
\zzz{85}{085}
\toacite{short}\index[cases]{Anda@\toacite{short}}

\newpage
\cite{auth2c}\index[cases]{TheDogCo@\citetitle{auth2c}, \citeauthor{auth2c}}
\cite{auth3c}\index[cases]{us@\citetitle{auth3c}, \citeauthor{auth3c}}

\newpage
\cite{auth2c}\index[cases]{TheDogCo@\citetitle{auth2c}, \citeauthor{auth2c}}
\zzz{123}{123}
\zzz{85}{085}

\citetitle[r 45(a)]{tcpr}\index[rules]{r 045@\citetitle[r 45(a)]{tcpr}}
\toacite{short}\index[cases]{Anda@\toacite{short}}

\newpage\citetitle{long}, \citeauthor{long}\index[cases]{Hereis@\citetitle{long}, \citeauthor{long}}
\newpage text
\newpage\citetitle{long}, \citeauthor{long}\index[cases]{Hereis@\citetitle{long}, \citeauthor{long}}
\newpage text
\newpage text
\newpage\citetitle{long}, \citeauthor{long}\index[cases]{Hereis@\citetitle{long}, \citeauthor{long}}
\newpage text
\newpage\citetitle{long}, \citeauthor{long}\index[cases]{Hereis@\citetitle{long}, \citeauthor{long}}
\newpage\toacite{short}\index[cases]{Anda@\toacite{short}}
\newpage text \newpage text\toacite{short}\index[cases]{Anda@\toacite{short}}
\newpage text\newpage text\newpage text
\newpage text\newpage text\newpage text\newpage text
\newpage text
\toacite{short}\index[cases]{Anda@\toacite{short}}
\newpage\citetitle{long}, \citeauthor{long}\index[cases]{Hereis@\citetitle{long}, \citeauthor{long}}
\newpage text
\newpage text\newpage text\newpage text\newpage text
\newpage text
\toacite{short}\index[cases]{Anda@\toacite{short}}
\newpage text
\toacite{short}\index[cases]{Anda@\toacite{short}}
\newpage text
\newpage text\newpage text\newpage text\newpage text
\toacite{short}\index[cases]{Anda@\toacite{short}}
%\citetitle{short}\index[cases]{\citetitle{short}, \citeauthor{short}}

\toacite{long}\index[cases]{Hereis@\citetitle{long}, \citeauthor{long}}

\bigskip
\hfill\rulesep\hfill\ %\hrule%{0.8\linewidth}
\bigskip

%===============================================

\end{document}
3
  • Thanks Cicada. This is very good, but not quite what I need. The main issue is that the citation and page numbers are treated as a single line of text so, when there are too many pages to fit on the line, the pages resume on the left with a hanging indent (as in the first case cited in you example). I would prefer the page numbers be a separate column or minipage or parbox so that, if there are too many, they break and can be right aligned. Similarly, I would prefer that the citation text never encroach on the box with the pages, as it does for the third case.
    – bbernicker
    May 30, 2023 at 2:17
  • Also, for my application, I only need it to work with raw text. It does not need to support .bib files.
    – bbernicker
    May 30, 2023 at 2:17
  • Sounds like an arrangement of vboxes and hboxes, possibly with alignments and fills.
    – Cicada
    May 30, 2023 at 7:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .