Browse Source

* Added nobib documentclass option to suppress loading of natbib (and redefinition of \cite).

git-svn-id: https://tufte-latex.googlecode.com/svn/trunk@173 516e2f36-ce3a-0410-bea4-1d4a03f5df72
master
Kevin M. Godby 14 years ago
parent
commit
9460b670e0
1 changed files with 44 additions and 21 deletions
  1. +44
    -21
      tufte-common.def

+ 44
- 21
tufte-common.def View File

@@ -39,6 +39,11 @@
\DeclareOptionX[tufte]<common>{ls}{\setboolean{@tufte@letterspace}{true}}
\DeclareOptionX[tufte]<common>{nols}{\setboolean{@tufte@letterspace}{false}}

%%
% `nobib' option -- doesn't load natbib or adjust the \cite command
\newboolean{@tufte@loadnatbib}\setboolean{@tufte@loadnatbib}{true}
\DeclareOptionX[tufte]<common>{nobib}{\setboolean{@tufte@loadnatbib}{false}}

%%
% `titlepage' option -- creates a full title page with \maketitle

@@ -865,17 +870,19 @@
%%
% Citations should go in the margin as sidenotes

\RequirePackage{natbib}
\RequirePackage{bibentry} % allows bibitems to be typeset outside thebibliography environment
% Redefine the \BR@b@bibitem command to fix a bug with bibentry+chicago style
\renewcommand\BR@b@bibitem[2][]{%
\ifthenelse{\isempty{#1}}%
{\BR@bibitem{#2}}%
{\BR@bibitem[#1]{#2}}%
\BR@c@bibitem{#2}%
}
\nobibliography* % pre-loads the bibliography keys
\providecommand{\doi}[1]{\textsc{doi:} #1}% pre-defining this so it may be used before the \bibliography command it issued
\ifthenelse{\boolean{@tufte@loadnatbib}}{%
\RequirePackage{natbib}%
\RequirePackage{bibentry}% allows bibitems to be typeset outside thebibliography environment
% Redefine the \BR@b@bibitem command to fix a bug with bibentry+chicago style
\renewcommand\BR@b@bibitem[2][]{%
\ifthenelse{\isempty{#1}}%
{\BR@bibitem{#2}}%
{\BR@bibitem[#1]{#2}}%
\BR@c@bibitem{#2}%
}%
\nobibliography*% pre-loads the bibliography keys
\providecommand{\doi}[1]{\textsc{doi:} #1}% pre-defining this so it may be used before the \bibliography command it issued
}{}

%%
% Normal \cite behavior
@@ -947,7 +954,9 @@
%%
% Set the default \cite style. This is set and reset by the \sidenote command.

\let\cite\@tufte@normal@cite
\ifthenelse{\boolean{@tufte@loadnatbib}}{%
\let\cite\@tufte@normal@cite
}{}

%%
% Transform existing \footnotes into \sidenotes
@@ -1038,7 +1047,9 @@

% #1 = footnote num, #2 = vertical offset, #3 = footnote text
\long\def\@tufte@sidenote[#1][#2]#3{%
\let\cite\@tufte@infootnote@cite% use the in-sidenote \cite command
\ifthenelse{\boolean{@tufte@loadnatbib}}{%
\let\cite\@tufte@infootnote@cite% use the in-sidenote \cite command
}{}%
\gdef\@tufte@citations{}% clear out any old citations
\ifthenelse{\NOT\isempty{#2}}{%
\gsetlength{\@tufte@sidenote@vertical@offset}{#2}%
@@ -1059,7 +1070,9 @@
\@footnotemark\@footnotetext[\@tufte@sidenote@vertical@offset]{#3}%
}%
\@tufte@print@citations% print any citations
\let\cite\@tufte@normal@cite% go back to using normal in-text \cite command
\ifthenelse{\boolean{@tufte@loadnatbib}}{%
\let\cite\@tufte@normal@cite% go back to using normal in-text \cite command
}{}%
\unskip\ignorespaces% remove extra white space
\kern-\multiplefootnotemarker% remove \kern left behind by sidenote
\kern\multiplefootnotemarker\relax% add new \kern here to replace the one we yanked
@@ -1072,11 +1085,15 @@
% Sidenote without the footnote mark

\newcommand\marginnote[2][0pt]{%
\let\cite\@tufte@infootnote@cite% use the in-sidenote \cite command
\ifthenelse{\boolean{@tufte@loadnatbib}}{%
\let\cite\@tufte@infootnote@cite% use the in-sidenote \cite command
}{}%
\gdef\@tufte@citations{}% clear out any old citations
\marginpar{\hbox{}\vspace*{#1}\@tufte@marginnote@font\@tufte@marginnote@justification\@tufte@margin@par\vspace*{-1\baselineskip}\noindent #2}%
\@tufte@print@citations% print any citations
\let\cite\@tufte@normal@cite% go back to using normal in-text \cite command
\ifthenelse{\boolean{@tufte@loadnatbib}}{%
\let\cite\@tufte@normal@cite% go back to using normal in-text \cite command
}{}%
}


@@ -1750,11 +1767,17 @@
% Redefine \bibsection to not mark the running heads.
% (Code modified from natbib.sty.)

\@ifundefined{chapter}%
{\renewcommand\bibsection{\section*{\refname}}}
{\@ifundefined{NAT@sectionbib}%
{\renewcommand\bibsection{\chapter{\bibname}}}
{\renewcommand\bibsection{\section*{\bibname}}}}
\ifthenelse{\boolean{@tufte@loadnatbib}}{%
\@ifundefined{chapter}{%
\renewcommand\bibsection{\section*{\refname}}%
}{%
\@ifundefined{NAT@sectionbib}{%
\renewcommand\bibsection{\chapter{\bibname}}%
}{%
\renewcommand\bibsection{\section*{\bibname}}%
}%
}%
}

%%
% An index environment to mimic Tufte's indexes


Loading…
Cancel
Save