22

Let's take article document class with bibliography:

\documentclass{article}
\begin{document}
Some text \cite{key01}.
\begin{thebibliography}{9}% 2nd arg is the width of the widest label.
\bibitem{key01}
Beeblebrox, Zaphod, Galactic University Press
etc. etc.`
\end{thebibliography}
\end{document}

Above list of bibliography entries there is References which looks like generates with: \section*{References} .

I would like it to look like default text.

How to change it ?

Should I \renewcommand to overwrite default \section ? If yes, how to revert default \section later ? If other more elegant option exists, could you provide ?

(pdflatex)

lockstep
  • 250,273
  • If you just want to change the name of the section: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=fixnam and http://tex.stackexchange.com/questions/17445/how-can-i-change-the-references-to-reference-in-the-thebibliography-environm – Jukka Suomela Aug 29 '12 at 00:22
  • You should accept Gonzalo's answer as it's way more elaborate and less prone to cause unexpected / unwanted behavior. – Tom Bombadil Aug 29 '12 at 09:58

2 Answers2

17

One option would be to use the titlesec package to locally redefine the section formatting:

\documentclass{article}
\usepackage{titlesec}

\begin{document}

\section{Test Section One}

\begingroup
\titleformat*{\section}{\normalfont}
\begin{thebibliography}{depth}
\bibitem{a} Test
\end{thebibliography}
\endgroup

\section{Test Section Two}

\end{document}

enter image description here

Another option is to patch the \thebibliography command to replace the default \section*{\refname} with \refname; this can be easily done with the help of the etoolbox package:

\documentclass{article}
\usepackage{etoolbox}

\patchcmd{\thebibliography}{\section*{\refname}}{\refname}{}{}

\begin{document}

\section{Test Section One}

\begin{thebibliography}{depth}
\bibitem{a} Test
\end{thebibliography}

\section{Test Section Two}

\end{document}

Without any packages, the necessary redefinition would be:

\documentclass{article}

\makeatletter
\renewenvironment{thebibliography}[1]
     {\refname%
      \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}%
      \list{\@biblabel{\@arabic\c@enumiv}}%
           {\settowidth\labelwidth{\@biblabel{#1}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
            \@openbib@code
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}
\makeatother

\begin{document}

\section{Test Section One}

\begin{thebibliography}{depth}
\bibitem{a} Test
\end{thebibliography}

\section{Test Section Two}

\end{document}

The last two examples produce the same output as the first one, so I didn't upload the repeated images.

Gonzalo Medina
  • 505,128
13

You can use the \let\store\macro command, which saves the current definition of \macro to \store.

The Code

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}

\begin{document}

\section{test}

\let\oldsection\section
\renewcommand*{\section}[1]{#1}

\section{new test}

\let\section\oldsection

\section{reverted?}

\end{document}

The Output ##

enter image description here


Edit 1: Much easier, fully working approach: use options inside \renewcommand{\refname}{}.

The Code

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}

\begin{document}

\section{test}

\renewcommand{\refname}{\normalfont\selectfont\normalsize References} 

\section{new test}

  \begin{thebibliography}{depth}
    \bibitem{atuning}Volker Wollny (Hrsg.): {\it Amiga--Tuning}.
                     Interest--Verlag, Augsburg, 1996.
  \end{thebibliography}

\section{reverted?}

\end{document}

The Output

enter image description here

Tom Bombadil
  • 40,123
  • 2
    I like more your first solution; using the second approach you are also silently modifying possible headers since \refname is used to produce them, and this could not be desirable. – Gonzalo Medina Aug 29 '12 at 03:50
  • @GonzaloMedina: But the first one doesn't work properly: it prints *References instead of References, due to the bibliography using section* I think. However trying the \let course as before fails for section*. – Tom Bombadil Aug 29 '12 at 03:58
  • You're right; first one doesn't work. – Gonzalo Medina Aug 29 '12 at 04:00