My university uses Harvard UTS referencing system. I have to write an engineering report and my references are more than 50. I think if I do all 50 references by hands, it takes too much time. So I would like to write a package and a bibtex style to ease the writing of references. Unfortunately I am not much familiar with bibtex. Can someone please help me writing a bibtex style file?
[Tex/LaTex] How to write a bibtex style for the university
bibtex
Related Solutions
In this example I used \parencite{key}
to put some parenthesis around the in text citation.
mythesis.tex
\documentclass[bibtotocnumbered]{article}
\usepackage[utf8]{inputenc}
\usepackage[style=authoryear,backend=biber]{biblatex}
\addbibresource{library.bib}
\begin{document}
\tableofcontents
\newpage
Some text to cite here \parencite[23]{Lin1973}.
Another text to cite here \parencite[123]{Goedel1930}.
\printbibliography[heading=bibintoc]
\end{document}
library.bib
% This file was created with JabRef 2.9.2.
% Encoding: UTF8
@BOOK{Goedel1930,
title = {Die Vollständigkeit der Axiome des logischen Funktionenkalküls},
publisher = {Monatshefte für Mathematik und Physik},
year = {1930},
author = {Kurt Gödel},
address = {Wien}
}
@ARTICLE{Lin1973,
author = {Shen Lin and Brian W. Kernighan},
title = {An Effective Heuristic Algorithm for the Travelling-Salesman Problem},
journal = {Operations Research},
year = {1973},
volume = {21},
pages = {498--516}
}
My Workflow:
pdflatex mythesis
biber mythesis
pdflatex mythesis
pdflatex mythesis
To edit your .bib file I would recommend you a reference manager like JabRef.
Make sure your files are encoded in UTF8.
The class has a definition for thebibliography
which really can't be recommended (add a \usepackage{showframe}
to see what I mean), and for some reason it is not getting used. However, if you add the following:
\def\thebibliography#1{%
\ifrawbibliography
\else
\newpage
\thispagestyle{empty}%
\addcontentsline{toc}{chapter}{REFERENCES}%
% Switch singlespace to after the heading gets printed.
\mainheading{REFERENCES}%
\par\removelastskip\singlespace\par\removelastskip% GBG Oct 1993
\fixmainheadingSKIP
\fi
\list{[\arabic{enumi}]}%
{\settowidth\labelwidth{[#1]}\leftmargin%
\labelwidth\advance\leftmargin\labelsep\usecounter{enumi}}%
\def\newblock{\hskip .11em plus .33em minus -.07em}%
\sloppy\clubpenalty4000\widowpenalty4000%
\sfcode`\.=1000\relax
}
to your document, the error about \newblock
not being defined will go away. You can add it to the main file as in the example below, or put the above definition into your own .sty
(called, say, languagebstfix.sty
) and load it with \usepackage
.
\documentclass[11pt,Chicago]{uuthesis}
% to make a self-contained example, we can use this package, which
% lets us create a bibliography file with the same name (except for
% the '.bib' extension) as the main file.
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{Levon07,
author = {Levon, Erez},
title = {{Sexuality in context}},
journal = {Language in Society},
year = {2007},
volume = {36},
pages = {533--554},
}
\end{filecontents}
\usepackage{thesis}% required by .cls
\usepackage{natbib}
%%% TAKEN FROM uuthesis2e.cls
\def\thebibliography#1{%
\ifrawbibliography
\else
\newpage
\thispagestyle{empty}%
\addcontentsline{toc}{chapter}{REFERENCES}%
% Switch singlespace to after the heading gets printed.
\mainheading{REFERENCES}%
\par\removelastskip\singlespace\par\removelastskip% GBG Oct 1993
\fixmainheadingSKIP
\fi
\list{[\arabic{enumi}]}%
{\settowidth\labelwidth{[#1]}\leftmargin%
\labelwidth\advance\leftmargin\labelsep\usecounter{enumi}}%
\def\newblock{\hskip .11em plus .33em minus -.07em}%
\sloppy\clubpenalty4000\widowpenalty4000%
\sfcode`\.=1000\relax
}
\begin{document}
A citation: \citep{Levon07}
\bibliographystyle{language}
\bibliography{\jobname}
\end{document}
Note also that there is a similar .cls
called uuthesis2e.cls. The differences seem superficial, but maybe it represents the 'preferred' version..?
As for this: ---
Basically I need to remove the
apostrophecomma after the Author name in the citation so it doesn't look like APA style and looks like LSA style (which I think the author of the language.bst) based his code off the APAcite code and so it still retains the apostrophe. How can I remove it based on the code?
--- with recent versions of natbib
, and as in the updated answer below, you can simply write:
\setcitestyle{aysep={}}
% with older versions (< version 8), you need to leave
% the 5th argument of `\bibpunct` empty; e.g.,
% \bibpunct{(}{)}{;}{a}{}{;}
Updated answer
Given the very custom spacing the class uses for its environments (all essentially localized versions of \list
with different settings), I think it is better to forgo the class' \def
of \thebibliography
and use one based off of the report
class, but tweaked for use with uuthesis.cls
(still not sure why there is also a uuthesis2e.cls
-- they seem at least mostly the same). So, here's how'd I do it:
\documentclass[11pt,Chicago,twoside]{uuthesis2e}
\usepackage{showframe}
% to make a self-contained example, we can use this package, which
% lets us create a bibliography file with the same name (except for
% the '.bib' extension) as the main file.
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{Levon07,
author = {Levon, Erez},
title = {{Sexuality in context context context context context context context context context context context context context context context}},
journal = {Language in Society},
year = {2007},
volume = {36},
pages = {533--554},
}
\end{filecontents}
\usepackage{thesis}% required by .cls
\newenvironment{thebibliography}{}{}% <-- keep natbib happy
\usepackage{natbib}
\setcitestyle{aysep={}}
%%% The following can be put into a .sty file and then loaded normally:
%%% FROM HERE:
% Set the 'hang' for the bibliography; length can be changed...
\newdimen\bibindent
\setlength\bibindent{1.5em}
% Set name for the 'thebibliography' environment
\renewcommand*{\bibname}{References}
\makeatletter % for the '@' in command names (not needed in a .sty file)
\newcommand\uuthesis@bibindent{% = \@openbib@code from natbib.sty
\advance\leftmargin\bibindent
\itemindent -\bibindent
\listparindent \itemindent
\parsep \z@
}%
\def\newblock{\hskip .11em\@plus.33em\@minus.07em}
\renewenvironment{thebibliography}[1]
{%
\thispagestyle{empty}%
\addcontentsline{toc}{chapter}{\bibname}% <-- prefix \MakeUpppercase for 'REFERENCES'
\mainheading{\MakeUppercase\bibname}% <-- uuthesis method
\par\removelastskip\singlespace\par\removelastskip% GBG Oct 1993
\fixmainheadingSKIP
\list{}%
{%
\advance\leftmargin-\leftmargin
\advance\leftmargin\bibindent
}%
\leftmargin\labelwidth
\uuthesis@bibindent
\sloppy
\clubpenalty4000
\@clubpenalty \clubpenalty
\widowpenalty4000%
\sfcode`\.\@m}
{\def\@noitemerr
{\@latex@warning{Empty `thebibliography' environment}}%
\endlist}
\makeatother % make '@' inaccessible again (not needed in a .sty)
%%% TO HERE:
\begin{document}
\noindent
A citation: \citep{Levon07}
\bibliographystyle{language}
\bibliography{\jobname}
\end{document}
One thing you might want to consider, depending on how 'into' the TeX world you become, is creating your own thesis that adheres to your university's regulations. You don't need to make a whole .cls
by any means, and by doing so, you will learn much more about how things fit together. Thesis requirements may often be draconian and typographically questionable, but they are usually quite easy to follow. (The difficulty is often managing to make the thing look nice despite the requirements for double-spacing, and so forth. And the danger is that it can become a sometimes-fun, sometimes-frustrating way to 'waste' time...)
Best Answer
It's always the best using a tool to create the bibliography. The standard mechanism for LaTeX is
bib
.biblatex
/biber
to create the bibliography.The complete steps and the interaction are well explained in most common introductions.
Using the standard compilation BibTeX you can use a predefined style. A collection of available styles and their results can be found here: BibTeX and bibliography
If you don't find a suitable style and you want to use BibTeX you can create your own style by using
custom-bib
which is also compatible withnatbib
.The second and most recommend method is the usage of
biblatex
. You can use a style provided by the package itself or you use a contributed style. The question/answer of Guidelines for customizing biblatex styles helps you for the first step.