Text FormattingChanging depth of the bibliography section's headline

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Changing depth of the bibliography section's headline

Post by svend_tveskaeg »

Hi all.

Consider the following example:

Code: Select all

\documentclass[danish]{article}

\usepackage{babel}
\addto\captionsdanish{\renewcommand\refname{Bibliografi}}
\usepackage{natbib}

\begin{document}

Horses and cows are awesome, just see \citep{klafki2005}.

\bibliographystyle{apalike}

\begin{thebibliography}{}

\bibitem[Klafki, 2005]{klafki2005}
Wolfgang, Klafki:
\newblock {\slshape Dannelsesteori og didaktik: Nye studier},
\newblock 2.~udgave, 2.~oplag, 2005.
\newblock {\scshape isbn-10}: 87-7955-196-3.

\end{thebibliography}

\end{document}
How do I get ``Bibliografi'' to be a subsection instead of a section?

Thank you in advance!
Last edited by svend_tveskaeg on Fri Apr 08, 2011 2:00 pm, edited 3 times in total.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Changing depth of the bibliography section's headline

Post by localghost »

svend_tveskaeg wrote:[…] How do I get ``Bibliografi'' to be a subsection instead of a section? […]
Pick up the code for the thebibliography environment from the »article« class and replace \section* with \subsection*. Don't forget to enclose the new definition with \makeatletter and \makeatother.

Code: Select all

\makeatletter
\renewenvironment{\thebibliography}[1]{%
…
}
\makeatother

Thorsten
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Changing depth of the bibliography section's headline

Post by svend_tveskaeg »

Thank you, Thorsten!

Now there is another problem, though. Consider the modified example below:

Code: Select all

\documentclass[danish]{article}

\usepackage{babel}
\addto\captionsdanish{\renewcommand\refname{Bibliografi}}
\usepackage{natbib}

\makeatletter
\renewenvironment{thebibliography}[1]
     {\subsection*{\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}

Horses and cows are awesome, just see \citep{klafki2005} and
\citep{klafki2006}.

\bibliographystyle{apalike}

\begin{thebibliography}{}

\bibitem[Klafki, 2005]{klafki2005}
Wolfgang, Klafki:
\newblock {\slshape Dannelsesteori og didaktik: Nye studier},
\newblock 2.~udgave, 2.~oplag, 2005.
\newblock {\scshape isbn-10}: 87-7955-196-3.

\bibitem[Klafki, 2006]{klafki2006}
Wolfgang, Klafki:
\newblock {\slshape Dannelsesteori og didaktik: Nye studier},
\newblock 2.~udgave, 2.~oplag, 2006.
\newblock {\scshape isbn-10}: 87-7955-196-3.

\end{thebibliography}

\end{document}
Here each \bibitem entry starts with the line indented as much as the rest of the lines. How do I avoid this indentation of the first line?

Thank you in advance!
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Changing depth of the bibliography section's headline

Post by localghost »

Side effects never can be ruled out completely. And this just seems to be one. At the moment I can't recognize a cause. Perhaps it's in the BibTeX style file.
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Changing depth of the bibliography section's headline

Post by svend_tveskaeg »

The apalike.sty file seem to use a macro called \bibhang but I have no idea if this is the key and if so, how to modify it.

Help will be much appreciated!
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Changing depth of the bibliography section's headline

Post by localghost »

Thanks to your hint with \bibhang I now see that redefining the »thebibliography« environment like I did in my first reply does not make sense. You have to take the code from the package itself and do the modification I suggested. Here is a complete solution free from unwanted side effects.

Code: Select all

\documentclass[11pt,a4paper,danish]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{natbib}

\addto\captionsdanish{%
  \renewcommand\refname{Bibliografi}
}

\makeatletter
\@ifundefined{chapter}{\def\thebibliography#1{\subsection*{\refname\@mkboth
  {\sl\uppercase{\refname}}{\sl\uppercase{\refname}}}\list
  {\relax}{\setlength{\labelsep}{0em}
        \setlength{\itemindent}{-\bibhang}
        \setlength{\leftmargin}{\bibhang}}
    \def\newblock{\hskip .11em plus .33em minus .07em}
    \sloppy\clubpenalty4000\widowpenalty4000
    \sfcode`\.=1000\relax}}%
{\def\thebibliography#1{\chapter*{\bibname\@mkboth
  {\sl\uppercase{\bibname}}{\sl\uppercase{\bibname}}}\list
  {\relax}{\setlength{\labelsep}{0em}
        \setlength{\itemindent}{-\bibhang}
        \setlength{\leftmargin}{\bibhang}}
    \def\newblock{\hskip .11em plus .33em minus .07em}
    \sloppy\clubpenalty4000\widowpenalty4000
    \sfcode`\.=1000\relax}}
\makeatother

\begin{document}
  Horses and cows are awesome, just see \citep{klafki2005} and \citep{klafki2006}.

  \bibliographystyle{apalike}
  \begin{thebibliography}{}
    \bibitem[Klafki, 2005]{klafki2005} Wolfgang, Klafki:
      \newblock \textsl{Dannelsesteori og didaktik: Nye studier},
      \newblock 2.~udgave, 2.~oplag, 2005.
      \newblock \textsc{isbn-10}: 87-7955-196-3.

    \bibitem[Klafki, 2005]{klafki2005} Wolfgang, Klafki:
      \newblock \textsl{Dannelsesteori og didaktik: Nye studier},
      \newblock 2.~udgave, 2.~oplag, 2005.
      \newblock \textsc{isbn-10}: 87-7955-196-3.
  \end{thebibliography}
\end{document}
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Re: Changing depth of the bibliography section's headline

Post by svend_tveskaeg »

This is spot on! Thank you very much for helping me!
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Changing depth of the bibliography section's headline

Post by localghost »

svend_tveskaeg wrote:This is spot on! […]
Then please mark the topic (not the last post) accordingly. In the meantime you should know that so that reminders actually should not be necessary any more.
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Re: Changing depth of the bibliography section's headline

Post by svend_tveskaeg »

You are absolutely correct; I apologise.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Changing depth of the bibliography section's headline

Post by svend_tveskaeg »

Here we go again. :oops:

I have now discovered that the ``Bibliografi'' \subsection does not get in the ToC when I use

Code: Select all

\usepackage[nottoc]{tocbibind}
Furthermore, the package gives me the following note:

Code: Select all

Package tocbibind Note: Using section or other style headings.
A compileable (is that even a word?) example is given below:

Code: Select all

\documentclass[11pt,a4paper,danish]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[nottoc]{tocbibind}
\usepackage{natbib}

\addto\captionsdanish{%
  \renewcommand\refname{Bibliografi}
}

\makeatletter
\@ifundefined{chapter}{\def\thebibliography#1{\subsection*{\refname\@mkboth
  {\sl\uppercase{\refname}}{\sl\uppercase{\refname}}}\list
  {\relax}{\setlength{\labelsep}{0em}
           \setlength{\itemindent}{-\bibhang}
           \setlength{\leftmargin}{\bibhang}}
   \def\newblock{\hskip .11em plus .33em minus .07em}
   \sloppy\clubpenalty4000\widowpenalty4000
   \sfcode`\.=1000\relax}}%
                      {\def\thebibliography#1{\chapter*{\bibname\@mkboth
  {\sl\uppercase{\bibname}}{\sl\uppercase{\bibname}}}\list
  {\relax}{\setlength{\labelsep}{0em}
           \setlength{\itemindent}{-\bibhang}
           \setlength{\leftmargin}{\bibhang}}
   \def\newblock{\hskip .11em plus .33em minus .07em}
   \sloppy\clubpenalty4000\widowpenalty4000
   \sfcode`\.=1000\relax}}
\makeatother

\begin{document}

\tableofcontents

\vspace{3cm}

\subsection{The Funnyfarm}
Horses and cows are awesome; see \citep{klafki2005} and \citep{klafki2006}.

\bibliographystyle{apalike}
\begin{thebibliography}{}
  \bibitem[Klafki, 2005]{klafki2005} Wolfgang, Klafki:
    \newblock \textsl{Dannelsesteori og didaktik: Nye studier},
    \newblock 2.~udgave, 2.~oplag, 2005.
    \newblock \textsc{isbn-10}: 87-7955-196-3.

  \bibitem[Klafki, 2006]{klafki2006} Wolfgang, Klafki:
    \newblock \textsl{Dannelsesteori og didaktik: Nye studier},
    \newblock 2.~udgave, 2.~oplag, 2006.
    \newblock \textsc{isbn-10}: 87-7955-196-3.
\end{thebibliography}

\end{document}
How do I fix this?

Thank you in advance, once again!

PS. The log file is attached.
Attachments
test2.log
The log file.
(14.51 KiB) Downloaded 268 times
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
Post Reply