5

I'm new to using LaTeX and am unsure of how to resolve errors that arise when trying to insert a line broken by text (as a header) into a bibliography. However, it does also happen at any other point in the document. For example, an excerpt of my code for the bibliography is shown below.

\begin{thebibliography}{4}

\hskip
\xrfill[0.7ex]{1pt}

\item{ITEM 1}

\hrule
\vspace{0.5cm}

\end{thebibliography}

The idea is to create a line at the top containing a section number, so that the references within that and the bottom line (the \hrule command) can be clearly attributed to the appropriate sections in a larger report. However, using:

\hskip
\xrfill[0.7ex]{1pt}

causes some errors to appear, not just in the bibliography. Specifically, on the line where the \xrfill function is called, a "Missing number, treated as zero" error appears. At item 1, an error saying "Something's wrong - perhaps a missing item" also appears. I have used the \xhfill package in my document preamble:

\usepackage{xhfill}

Any help with this would be appreciated.

Edit: A sketch of what I wanted it to look like:

Sketch of Bibliography

1
  • Hi Sam, thanks. I've updated the post to include a rough sketch of what I wanted it to look like. I can add more detail if you need. Nov 13, 2018 at 15:58

1 Answer 1

4

You could do something like the following:

\documentclass{article}

\usepackage{graphicx}

\newcounter{myline}

\newcommand{\myline}{%
    \addtocounter{myline}{1}
    \item[] \hskip-1.8em \hrulefill \raisebox{-0.8ex}{~Section \themyline} \hrulefill\vspace*{0.8ex}
}

\begin{document}

\begin{thebibliography}{9}

\myline

\bibitem{notes} John W. Dower \emph{Readings compiled for History 21.479.} 1991.

\bibitem{impj}  The Japan Reader {\em Imperial Japan 1800-1945} 1973: Random House, N.Y.

\myline

\bibitem{notesa} John W. Dower \emph{Readings compiled for History 21.479.} 1991.

\bibitem{impja}  The Japan Reader {\em Imperial Japan 1800-1945} 1973: Random House, N.Y.

\myline

\bibitem{notesb} John W. Dower \emph{Readings compiled for History 21.479.} 1991.

\bibitem{impjb}  The Japan Reader {\em Imperial Japan 1800-1945} 1973: Random House, N.Y.
\end{thebibliography}

\end{document}

enter image description here

4
  • This worked rather well. Assuming I have a reference in each section (1-7) then this will be perfect for the document I'm producing. Thanks again. Nov 13, 2018 at 20:15
  • @SaifSaleem You're welcome! Nov 13, 2018 at 20:30
  • @SaifSaleem In case you won't have a reference in each section, you can skip sections by using \addtocounter{myline}{1} Nov 13, 2018 at 20:31
  • I didn't think of that. Thanks again for answering the post. You're a legend. Nov 13, 2018 at 23:55

You must log in to answer this question.

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