Thursday, August 23, 2007

LaTeX for generating Behavioral Ecology manuscript

UPDATE: Check out a more complete math-oriented template/example, that I posted as behavecol_math_template.tex. This is ready to use out of the box. It has comments. It is setup for AMS math. It has table, figure, and autoreferencing examples too.

IMPORTANT NOTE: If using amsmath environments, be sure to check out my information on making lineno compatible with amsmath environments.

UPDATE: I have put behavecol_template.tex and behavecol.bst on-line so that you don't have to do any of the following to get them.

The Oxford Journal Behavioral Ecology is not setup for LaTeX manuscript submissions. This baffles me.

So, I spent some time putting together some macros and a BibTeX style file to get up and running with this journal.

First, a template (that uses the article document class), which fixes incompatibilities between figcaps, caption, and anything that uses \ref (see behavecol_template.tex for what is below, or see behavecol_math_template.tex for a more complete example):
\documentclass[12pt]{article}

\usepackage[paper=letterpaper,margin=1.5in]{geometry}
\usepackage{setspace}\doublespacing

\usepackage{graphicx}

\usepackage[%
labelsep=newline,
justification=RaggedRight,
singlelinecheck=false,
labelfont=bf,
tableposition=top,
]{caption}
\captionsetup[table]{textfont=bf,position=above}
\makeatletter
\let\oldmakecaption\@makecaption
\makeatother

\usepackage[figon,printfigures]{figcaps}
\def\figurecapname{Figure legends}
\def\tablepagename{Tables}
\def\figurepagename{Figures}

\makeatletter
% This lets figcaps work with \ref
% However, forces \label outside of \caption
\def\phantomsection{\relax}
\let\oldfigurepage\@figurepage
\def\@figurepage{%
\@ifundefined{tf@pof}{}{%
\let\oldlabel\label%
\let\oldinput\@input%
\def\@input{\def\label{\oldlabel}\oldinput}%
\phantomsection%
\addcontentsline{toc}{section}{\figurepagename}}%
\oldfigurepage%
}
\let\@makefcaption\@makecaption
\let\oldtablepage\@tablepage
\def\@tablepage{%
\@ifundefined{tf@pot}{}{%
\clearpage%
\phantomsection%
\addcontentsline{toc}{section}{\tablepagename}}%
\oldtablepage%
}
\makeatother
\usepackage[subrefformat=subparens,labelformat=parens]{subfig}
\captionsetup[subfloat]{position=top}

\setcounter{secnumdepth}{0}

% Lines are numbered, starting at 1
% (add pagewise to reset at each page)
%\usepackage[modulo,pagewise,mathlines]{lineno}
\usepackage[modulo,mathlines]{lineno}
\modulolinenumbers[1]
\firstlinenumber{1}
\linenumbers

\usepackage{natbib}
\bibliographystyle{behavecol}
\setcitestyle{%
authoryear,round,semicolon,%
aysep={},%
yysep={,},%
notesep={, }%
}

\usepackage{tocbibind}
\def\tocbibname{\refname}

\usepackage{varioref}
\labelformat{equation}{\textup{(#1)}}
\labelformat{enumi}{\textup{(#1)}}

\usepackage[%
pdftitle={},
pdfsubject={},
pdfauthor={},
pdfkeywords={},
pdfstartview=FitH,
bookmarks=true,bookmarksopen=true,
breaklinks=true,
colorlinks=false,
pdfpagelabels=true,hypertexnames=true,
plainpages=false,naturalnames=false,
%draft,
]{hyperref}

% \Autoref is for the beginning of the sentence
\let\orgautoref\autoref
\providecommand{\Autoref}
{\def\equationautorefname{Equation}%
\def\figureautorefname{Figure}%
\def\subfigureautorefname{Figure}%
\def\Itemautorefname{Item}%
\def\tableautorefname{Table}%
\orgautoref}

% \Autorefs is plural for the beginning of the sentence
\providecommand{\Autorefs}
{\def\equationautorefname{Equations}%
\def\figureautorefname{Figures}%
\def\subfigureautorefname{Figures}%
\def\Itemautorefname{Items}%
\def\tableautorefname{Tables}%
\orgautoref}

% \autoref is used inside a sentence
% (renew of the standard autoref)
\renewcommand{\autoref}{\Autoref}

% \autorefs is plural for inside a sentence
\providecommand{\autorefs}{\Autorefs}

\let\oldsection\section
\newcommand{\uppercasesection}[2][]{%
\oldsection[#1]{\MakeUppercase{#2}}}
\newcommand{\uppercasesectionstar}[1]{%
\oldsection*{\MakeUppercase{#1}}}
\makeatletter
\def\section{%
\@ifstar{\uppercasesectionstar}%
{\@dblarg{\uppercasesection}}}
\makeatother

\hypersetup{%
pdftitle=
{The title},
}
\title{The title}
\author{}
\date{}

\begin{document}

\maketitle

\begin{abstract}
% ...The abstract...
\textit{Key words:} Keywords separated with comma+space,
List ends with period.
\hypersetup{%
pdfkeywords=
{Keywords separated with comma+space,
List ends with period},
}
\end{abstract}
\newpage

% ...The document...

% The following line loads the references
\bibliography{the_bib_database_name}

\end{document}
Of course, remember to put table captions before the actual table insertion. In fact, it is important that the inside of a table environment has caption first, then label OUTSIDE of the caption, then the actual table content. Additionally, subfigures should be inserted (within a figure environment) with something like:
\subfloat[]{
% ... something like an \includegraphics ...
\label{fig:a}
}
Also, when you're ready to submit, get rid of the % on the %draft, line of the hyperref options. This will turn off all hyper linking, which will prevent strange little unlinked boxes from being drawn in your autogenerated proof.

Next, the bibliography style file, which I may end up posting later separately. As of right now, it has to be constructed from pieces. First, save the following as behavecol.dbj (see behavecol_full.dbj for more details):
%% Driver file to produce behavecol.bst from merlin.mbs
%% Generated with makebst, version 4.1 (2003/09/08)
%% Produced on 2007/08/23 at 12:02
%%
\input docstrip

\preamble
----------------------------------------
*** Bibliography style for _Behavioral Ecology_. ***

\endpreamble

\postamble
End of customized bst file
\endpostamble

\keepsilent

\askforoverwritefalse
\def\MBopts{\from{merlin.mbs}{%
ay,nat,nm-rvx,ed-rev,jnrlst,keyxyr,dt-beg,yr-per,note-yr,jxper,%
jttl-rm,thtit-a,vnum-x,pp-last,num-xser,btit-rm,bt-rm,add-pub,%
pre-edn,in-col,pp,abr,ednx,ord,jabr,xand,etal-xc,nfss,}}
\generate{\file{behavecol.bst}{\MBopts}}
\endbatchfile
and then run latex behavecol.dbj. Next, save the following to behavecol.patch:
--- behavecol.bst 2007-08-29 12:07:40.000000000 -0400
+++ behavecol_new.bst 2007-08-29 12:08:01.000000000 -0400
@@ -89,7 +89,7 @@
FUNCTION {output.nonnull}
{ 's :=
output.state mid.sentence =
- { ", " * write$ }
+ { ". " * write$ }
{ output.state after.block =
{ add.period$ write$
newline$
@@ -144,6 +144,9 @@
FUNCTION {add.blank}
{ " " * before.all 'output.state :=
}
+FUNCTION {add.semicolon}
+{ ";" * before.all 'output.state :=
+}

FUNCTION {date.block}
{
@@ -248,7 +251,7 @@
{ "in" }

FUNCTION {bbl.pages}
-{ "pp." }
+{ "p." }

FUNCTION {bbl.page}
{ "p." }
@@ -260,10 +263,10 @@
{ "Tech. Rep." }

FUNCTION {bbl.mthesis}
-{ "Master's thesis" }
+{ "[Master's thesis]" }

FUNCTION {bbl.phdthesis}
-{ "Ph.D. thesis" }
+{ "[PhD thesis]" }

FUNCTION {bbl.first}
{ "1st" }
@@ -488,6 +491,16 @@
}
if$
}
+FUNCTION {format.book.pages}
+{ pages "pages" bibinfo.check
+ %duplicate$ empty$ 'skip$
+ empty$ 'skip$
+ { add.semicolon
+ add.blank
+ pages "pages" bibinfo.check
+ " " * bbl.pages * }
+ if$
+}
FUNCTION {format.note}
{
note empty$
@@ -950,6 +963,10 @@
}
if$
}
+FUNCTION {format.university.address}
+{ school "school" bibinfo.warn format.org.or.pub
+}
+
FUNCTION {format.publisher.address}
{ publisher "publisher" bibinfo.warn format.org.or.pub
}
@@ -1148,12 +1165,11 @@
author format.key output
format.date "year" output.check
date.block
- format.title
- "title" output.check
- new.block
+ format.title "title" output.check
+ add.blank
bbl.mthesis format.thesis.type output.nonnull
- school "school" bibinfo.warn output
- address "address" bibinfo.check output
+ format.university.address output
+ format.book.pages output
new.block
format.note output
fin.entry
@@ -1178,12 +1194,11 @@
author format.key output
format.date "year" output.check
date.block
- format.title
- "title" output.check
- new.block
+ format.title "title" output.check
+ add.blank
bbl.phdthesis format.thesis.type output.nonnull
- school "school" bibinfo.warn output
- address "address" bibinfo.check output
+ format.university.address output
+ format.book.pages output
new.block
format.note output
fin.entry
Then run
patch < behavecol.patch
from the same directory that you ran the DBJ command in. That should generate the behavecol.bst file that is needed for the above template to work.

2 comments:

Anonymous said...

Thank you very much! Your behavecol.tex template and the accompaining .bst file saved me a lot of time and effort.

Unknown said...

Wow, thanks for this. It just made my life a lot easier!