Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Biblatex port #10

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 85 additions & 21 deletions cvpr.sty
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,105 @@
% * "rebuttal" for the author rebuttal.
%
% specify references as
% {\small
% \bibliographystyle{ieee}
% \bibliography{...your files...}
% }
% \addbibresource{references.bib}
% in the preamble
% ---------------------------------------------------------------

\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{cvpr}[2024 Example LaTex class for IEEE CVPR]

\RequirePackage{times} % Integrate Times for here
\RequirePackage{cite} % Automatically ordered citations
\RequirePackage{xspace}
\RequirePackage{graphicx}
\RequirePackage{amsmath}
\RequirePackage{amssymb}
\RequirePackage{booktabs}
\RequirePackage[numbers,sort&compress]{natbib}
\setlength{\bibsep}{1pt plus 1pt minus 1pt}
%\setlength{\bibsep}{1pt plus 1pt minus 1pt}

\RequirePackage{silence} % Suppress unwanted warnings
\hbadness=10000 \vbadness=10000 \vfuzz=30pt \hfuzz=30pt
\WarningFilter{latexfont}{Font shape declaration}
\WarningFilter{latex}{Font shape}
\WarningFilter{hyperref}{Token not allowed in a PDF string}
\WarningFilter[rebuttal]{latex}{No \author given}
\RequirePackage{etoolbox}
\RequirePackage{etoolbox}%% <- for \pretocmd, \apptocmd and \patchcmd
\RequirePackage{xpatch}% for patching biblatex

% Use modern caption package to allow for sub-figures etc.
% Reproduces the original CVPR/ICCV style as closely as possible.
\RequirePackage[format=plain,labelformat=simple,labelsep=period,font=small,compatibility=false]{caption}
\RequirePackage[font=footnotesize,skip=3pt,subrefformat=parens]{subcaption}

%% References

% Breaking lines for URLs in the bib
\RequirePackage[hyphens]{url}
%todo check if this below is needed
\Urlmuskip=0mu plus 1mu\relax

\RequirePackage[
backend=biber,
style=ieee,
sorting=noneyear,
backref=true,
natbib=true, % add citep and citet
giveninits=true, % abbreviate the authors names, i.e., put only the initials
]{biblatex}

% Remove strings from the pageref
\DefineBibliographyStrings{english}{%
backrefpage ={},% originally "cited on page"
backrefpages ={},% originally "cited on pages"
}

%% Adapting the default style to CVPR's quirks

% Removes the parenthesis from the backref
%\DeclareFieldFormat{nobackrefparens}{#1}
%\xpatchbibmacro{pageref}{parens}{nobackrefparens}{}{\PackageWarningNoLine{cvpr}{Error patching pageref bibmacro. Let the maintainers know that the patch is not working.}}

% Remove spurious white space from pageref when using no string
\xpatchbibmacro{pageref}{\ppspace}{}{}{\PackageWarningNoLine{cvpr}{Error patching pageref bibmacro. Let the maintainers know that the patch is not working.}}
\xpatchbibmacro{pageref}{\ppspace}{}{}{\PackageWarningNoLine{cvpr}{Error patching pageref bibmacro. Let the maintainers know that the patch is not working.}}

% Revert unit divider to period
\renewcommand*\newunitpunct{\addperiod\addspace}

% Change format of volume-number-editor
\DeclareFieldFormat*{volume}{#1}

\renewbibmacro*{volume+number+eid}{%
\printfield{volume}%
\printfield[parens]{number}%
\setunit{\addcolon\addspace}%
\printfield{eid}%
}

% Change pages separator to colon on article
\renewcommand{\bibpagespunct}{\ifentrytype{article}{\addcolon\addspace}{\addcomma\addspace}}
\DeclareFieldFormat[article,incollection]{pages}{#1}

% Remove quotes from titles
\DeclareFieldFormat*{title}{#1}



% Sorts by appearance globally and by year within the citation
% https://tex.stackexchange.com/a/55451/7561
\DeclareSortingTemplate{noneyear}{
\sort{\citeorder}
\sort{\field{year}}
\sort{\field{author}}
}

% Change the normal space to a non-breaking one between the names and the reference
% https://tex.stackexchange.com/a/74932/7561
\renewcommand\namelabeldelim{\addnbspace}

% Make the fontsize small
\renewcommand*{\bibfont}{\normalfont\small}



\newtoggle{cvprfinal} % Camera-ready version
\newtoggle{cvprrebuttal} % Rebuttal
Expand All @@ -68,9 +135,7 @@
\ActivateWarningFilters[rebuttal]
}{}

% Breaking lines for URLs in the bib
\RequirePackage[hyphens]{url}
\Urlmuskip=0mu plus 1mu\relax



% ---------------------------------------------------------------
Expand Down Expand Up @@ -395,13 +460,14 @@
\PackageWarningNoLine{cvpr}{Package `hyperref' is not loaded, but highly recommended for camera-ready version}
}
}{%
\@ifpackageloaded{hyperref}{
\@ifpackagewith{hyperref}{pagebackref}{}{
\PackageWarningNoLine{cvpr}{Package `hyperref' is not loaded with option `pagebackref', which is strongly recommended for review version}
}
}{%
\PackageWarningNoLine{cvpr}{Package `hyperref' is not loaded, but strongly recommended for review version}
}
%todo biblatex options are not recognized since it is not "loaded" now. Probably, we need to add some check up code as suggested here https://tex.stackexchange.com/a/287673/7561
% \@ifpackageloaded{biblatex}{
% \@ifpackagewith{biblatex}{backref}{}{
% \PackageWarningNoLine{cvpr}{Package `biblatex' is not loaded with option `backref', which is strongly recommended for review version}
% }
% }{%
% \PackageWarningNoLine{cvpr}{Package `biblatex' is not loaded, but strongly recommended for review version}
% }
}
}

Expand Down Expand Up @@ -505,8 +571,6 @@
% Patch amsmath commands so that the previous line and the equation itself
% are numbered. Bug: multiline has an extra line number.
% https://tex.stackexchange.com/questions/461186/how-to-use-lineno-with-amsmath-align
\RequirePackage{etoolbox} %% <- for \pretocmd, \apptocmd and \patchcmd

\newcommand*\linenomathpatch[1]{%
\expandafter\pretocmd\csname #1\endcsname {\linenomath}{}{}%
\expandafter\pretocmd\csname #1*\endcsname {\linenomath}{}{}%
Expand Down Expand Up @@ -592,7 +656,7 @@

% ---------------------------------------------------------------

%% redefine the \title command so that a variable name is saved in \thetitle, and provides the \maketitlesupplementary command
%% redefine the \title command so that a variable name is saved in \thetitle, and provides the \maketitlesupplementary command
\let\titleold\title
\renewcommand{\title}[1]{\titleold{#1}\newcommand{\thetitle}{#1}}
\def\maketitlesupplementary
Expand Down
18 changes: 10 additions & 8 deletions main.tex
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
% !BIB program=biber
% CVPR 2024 Paper Template; see https://github.com/cvpr-org/author-kit

\documentclass[10pt,twocolumn,letterpaper]{article}
Expand All @@ -12,12 +13,15 @@

% It is strongly recommended to use hyperref, especially for the review version.
% hyperref with option pagebackref eases the reviewers' job.
% Please disable hyperref *only* if you encounter grave issues,
% Please disable hyperref *only* if you encounter grave issues,
% e.g. with the file validation for the camera-ready version.
%
% If you comment hyperref and then uncomment it, you should delete *.aux before re-running LaTeX.
% (Or just hit 'q' on the first LaTeX run, let it finish, and you should be clear).
\usepackage[pagebackref,breaklinks,colorlinks]{hyperref}
\usepackage[breaklinks,colorlinks]{hyperref}

% Add your own bibliography
\addbibresource{main.bib}

%%%%%%%%% PAPER ID - PLEASE UPDATE
\def\paperID{*****} % *** Enter the Paper ID here
Expand Down Expand Up @@ -46,15 +50,13 @@

\begin{document}
\maketitle
\input{sec/0_abstract}
\input{sec/0_abstract}
\input{sec/1_intro}
\input{sec/2_formatting}
\input{sec/3_finalcopy}
{
\small
\bibliographystyle{ieeenat_fullname}
\bibliography{main}
}

\printbibliography

\input{sec/X_suppl}

\end{document}