3

I want to break some lines in a document into 3 sections such that the first letter of each section is always directly below the other, slightly like a table, but I don't want to use the table environnment.

My current code is:

  \documentclass[11pt,a4paper]{scrreprt}
  \pagenumbering{gobble}
  \usepackage[english]{babel}
  \linespread{1.25}
  \usepackage[top=1.5cm, bottom=1cm, left=1.25cm, right=1.25cm]{geometry}
  \usepackage{changepage}
  \begin{document}
  \normalsize\textbf{Book title}\hspace{3.3cm}\textbf{Author's name}\hspace{5.4cm} 2010\\
  \hangindent=4.25cm
  \hangafter=0 This book is about some guy who wrote a book because he felt like a book would be a good thing to write.....etc etc etc
  \normalsize\textbf{Book title 2}\hspace{3.1cm}\textbf{Longer Author's name}\hspace{4.9cm} 1991\\
  \hangindent=4.25cm 
  \hangafter=0 This book is about a woman.....etc etc

  \end{document}

As you can see I have placed \hspace commands mid line to produce the required spacing, but it's very tedious to do this for many enteries. Is there a better way that doesn't involve using the table environment?

enter image description here

  • I added an image of your document. Could you confirm that's really the layout you want with longer author's name wrapping to the start of the next line? – David Carlisle Nov 19 '14 at 13:23
  • why don't you want to use a table (or tabbing) ? – David Carlisle Nov 19 '14 at 13:24
4

One non-tabular approach using the tabto package:

\documentclass[11pt,a4paper]{scrreprt}
\usepackage{tabto}
\parindent0pt
\parskip.5em
\begin{document}
\NumTabs{3}

\noindent {\bfseries Book title} \tab{\bfseries Author's name} \tab{2010}

This book is about some guy who wrote a book because he felt like a book would be a good thing to write.....etc etc etc

{\bfseries Book title 2} \tab{\bfseries Longer Author's name} \tab{1991}

This book is about a woman\ldots etc. etc.

\end{document}

MWE

However, note that this could be the wrong way if you have some very long names. In this case you can use \parbox and \hfill. Example:

\documentclass[11pt,a4paper]{scrreprt}
\def\tab#1{\parbox[t]{.3\linewidth}{#1}\hfill}
\parindent0pt
\parskip.5em
\begin{document}

\tab{\bfseries Book title} \tab{\bfseries Author's name} \tab{2010}

This book is about some guy who wrote a book because he felt like a book would be a good thing to write.....etc etc etc

\tab{\bfseries Book title 2} \tab{\bfseries Very very very long Author's name} \tab{1991}

This book is about a woman\ldots etc. etc.

\end{document}

MWE2

  • I think this is the easiest to implement. If I wanted to adjust the tab width, so you might have, across a page, parboxes of 0.1, 0.3 and 0.6. What would I need to do with the code? I assume I can use a hanging indent for the description text – Magiclamarshmallow Jan 5 '15 at 12:40
  • @Magiclamarshmallow With some like \newcommand\Tab[2]{\tab{\parbox[t]{\dimexpr.#1\linewidth-.7em}{#2}}} and then \NumTabs{10} you can use custom tabs like \Tab{3}{Long text} to have a width nearly to 30% of the line (minus -0.7em because must be some space between tabs). – Fran Jan 6 '15 at 11:12
1

You can use \makebox to specify the width of the blocks. As the other answer shows, are other box commands that will give you other options like text wrapping (see texdoc lshort). If you want the date flush right you can just put an \hfill before it.

This will all be simpler to write if you define a macro that spaces and formats your headers so that you can use semantic markup.

\documentclass{article}
\usepackage{lipsum}

\newcommand{\pubTitleAuthorYear}[3]{%
    \noindent%
    \makebox[0.5\linewidth][l]{\textbf{#1}}% book title
    \makebox[\width][l]{\textbf{#2}}% author name
    \hfill%
    #3% year
    \smallskip\par%
}
\newcommand{\pubInfo}[1]{\noindent #1\medskip\par}

\begin{document}

\pubTitleAuthorYear{Book One}{Author One}{2010}
\pubInfo{\lipsum[1]}

\pubTitleAuthorYear{Book Two}{Author Two}{2011}
\pubInfo{\lipsum[2]}

\end{document}

You could substitute the widths of the boxes and the formatting of their contents with separate macros if you wanted easier configuration of the layout. E.g., \newlength{\bookTitleWidth} \setlength{\bookTitleWidth}{0.5\textwidth} and \newcommand{\bookTitleFont}[1]{\textbf{\emph{#1}}}.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.