4

I'm looking to create a list where each item in the list will include a title followed by an author/name.

Obviously I could easily do that using any sort of basic document class (article, or paper come to mind) however I was wondering if there is a specific document class which is made specifically for lists.

Eabryt
  • 145
  • So, each list item has two (and only two) components: A title, and an author's name? How long might this list be: several pages long, or less than a page? Are the titles and names supposed to be typeset flush-left or centered? What about line spacing: single-spacing, double-spacing, or something else entirely? Is there anything else that's supposed to be shown, such as page numbers and/or headers? – Mico Feb 04 '15 at 19:10
  • @Mico Honestly not sure on the length. It's something that will grow without bound. I would say that items should be flush-left, and line spacing could be single or double. Although single would probably look better. This is mostly going to be used for personal use, with possible expansion if it looks nice enough. – Eabryt Feb 04 '15 at 19:21

3 Answers3

3

Here is a simple solution that you could build on. You can use a \parbox for the authors and titles. By specifying that all the parboxes are the same width, they will align as though in a table. (EDIT You can also use a tabular: see below.)

There is no limit on the length, as each \work entry is treated as a paragraph and TeX will break between them as needed. You can control the spacing between entries by changing the \parskip (e.g., \usepackage{parskip}).

You could also make separate boxes for last name and first name, or apply other styling (e.g., all the last names in bold).

\documentclass{article}

\newlength{\authorwidth}
\newlength{\titlewidth}
\setlength{\authorwidth}{0.25\linewidth} % adjust as desired
\setlength{\titlewidth}{0.25\linewidth}

\newcommand{\work}[2]{%
    \noindent
    \parbox[t]{\authorwidth}{#1}%
    \parbox[t]{\titlewidth}{\emph{#2}}\par%
}

\begin{document}
\work{John Doe}{Big Book}
\work{Jane Doe}{Bigger Book}
\work{Jim Doe}{Small Book}
\work{John Doe}{Big Book}
\work{Jane Doe}{Bigger Book}
\work{Jim Doe}{Small Book}
\work{John Doe}{Big Book}
\work{Jane Doe}{Bigger Book}
\work{Jim Doe}{Small Book}
\work{John Doe}{Big Book}
\work{Jane Doe}{Bigger Book}
\work{Jim Doe}{Small Book}

\end{document}

enter image description here

EDIT

For more customization, define a generic command to set up the boxes and then use that to make specific commands with formatting.

\newcommand{\pair}[2]{%
    \noindent
    \parbox[t]{\authorwidth}{#1}%
    \parbox[t]{\titlewidth}{#2}\par%
}
\newcommand{\pairHeader}[2]{%
    \pair{\textbf{#1}}{\textbf{#2}}\smallskip%
}
\newcommand{\work}[2]{%
    \pair{#1}{\emph{#2}}%
}

\begin{document}

\pairHeader{Author}{Title}
\work{John Doe}{Big Book}
...

@egreg is right, though, that if the boxes are more than one line then there is not enough space after them, unless you fix the spacing manually as he demonstrates. But perhaps this isn't a concern.


EDIT 2: TABULAR VERSION

To fix that alignment problem, instead of using parboxes, you can use a one-row tabular environment for each row. With tabularx you only need to specify the width of the first column. This does produce "Underfull \hbox" warnings, though.

\documentclass{article}
\usepackage{tabularx}
\newlength{\authorwidth}
\setlength{\authorwidth}{0.5\linewidth} % adjust as desired

\newcommand{\pair}[2]{%
    \noindent
    \begin{tabularx}{\linewidth}{p{\authorwidth} X}
    #1 & #2\\
    \end{tabularx}\par%
}
\newcommand{\pairHeader}[2]{%
    \pair{\textbf{#1}}{\textbf{#2}}\smallskip%
}
\newcommand{\work}[2]{%
    \pair{#1}{\emph{#2}}%
}

\begin{document}

\pairHeader{Author}{Title}

\work{John Doe}{Big Book}
\work{Jane Doe}{Bigger Book}
\work{Jim Doe}{Small Book}
\work{Jane Doe}{Bigger Book with a long title that will use two lines}
\work{Charles Louis Xavier~Joseph de~la Vall\'ee~Poussin}{Small Book}
\work{Adalbert Uthor}{All about authors}                          

\end{document}

enter image description here

musarithmia
  • 12,463
  • 1
    If a title needs two lines, the vertical spacing won't be uniform. – egreg Feb 04 '15 at 22:21
  • I actually really like this, and it seems to work really well. Let's say at the top I wanted column headers (title/author) Right now I have it as: \work{title}{author} Is there some way to distinguish it and maybe make the font a bit bigger for that individual work? – Eabryt Feb 04 '15 at 23:08
  • @Eabryt Yes, see the edit above. – musarithmia Feb 05 '15 at 03:27
  • @Eabryt Or, I realized you can use tabulars instead of parboxes and then you don't have the spacing problem: see edit 2. – musarithmia Feb 05 '15 at 03:41
2

For such an application I wouldn't use longtable; just boxes for coping with long titles (or authors with long names).

Some tricks are however necessary for getting correct and uniform vertical spacing (see How to keep a constant baselineskip when using minipages (or \parboxes)?)

\documentclass{article}

\newlength{\authorwidth}
\newlength{\titlewidth}
\setlength{\authorwidth}{0.3\columnwidth} % adjust as desired
\setlength{\titlewidth}{0.6\columnwidth} % adjust as desired

\newcommand{\work}[2]{%
  \noindent
  \parbox[t]{\titlewidth}{%
    \raggedright\itshape#2\par
    \xdef\titledepth{\the\prevdepth}%
    \xdef\titlelines{\the\prevgraf}%
  }%
  \hspace{\dimexpr\columnwidth-\titlewidth-\authorwidth}%
  \parbox[t]{\authorwidth}{%
    \raggedright#1\par
    \xdef\authordepth{\the\prevdepth}%
    \xdef\authorlines{\the\prevgraf}%
  }%
  \par
  \prevdepth=\ifnum\authorlines>\titlelines\space\authordepth\else\titledepth\fi
  \medskip
}

\begin{document}
\work{John Doe}{Big Book}
\work{Jane Doe}{Bigger Book with a long title that will use two lines}
\work{Charles Louis Xavier~Joseph de~la Vall\'ee~Poussin}{Small Book}
\work{Adalbert Uthor}{All about authors}
\end{document}

Having a \work macro allows to separate input and formatting; the formatting can be changed at will in the definition of \work.

(I was clearly inspired by Andrew Cashner's answer, but did a few improvements and changes.)

enter image description here

After setting title and author name, I save the depth of the last line and the number of lines, to be used after setting the boxes in order to get uniform spacing. Forced new lines in the title or in the author name should be marked by \\, not by a blank line.

egreg
  • 1,121,712
1

I strongly doubt that there's a LaTeX document class out there that "does" just the type of list you're interested in. I must confess to be entirely unaware of a LaTeX package that does just this -- and nothing else.

At any rate, it's not difficult to set up a longtable environment to do what you're interested in. A longtable can span many pages. By using (a modified form of) the p column type for both columns, titles and names will wrap automatically if their lengths exceed the allotted column widths. Feel free to fine-tune the widths of the columns and the information given in the header.

\documentclass{article}
\usepackage{longtable} % for 'longtable' environment
\usepackage{booktabs}  % for \midrule and \bottomrule macros
\usepackage{array}     % for \newcolumntype and \extrarowheight macros
\usepackage{ragged2e}  % for \RaggedRight macro
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1}}
\setlength\extrarowheight{1ex}   % provide a bit more space between entries
\usepackage{lipsum}    % for filler text

\begin{document}
\begin{longtable}{@{} P{0.4\textwidth} @{\hspace{0.05\textwidth}} P{0.55\textwidth} @{}}
Title & Author's name\\ \midrule \endhead
\bottomrule \endlastfoot
x & y\\
x & y\\
\lipsum*[2] & \lipsum*[3]\\
x & y\\
x & y\\
x & y\\
x & y\\
x & y\\
x & y\\
x & y\\
x & y\\
x & y\\
x & y\\
x & y\\
\end{longtable}
\end{document}
Mico
  • 506,678