1

I have the following document preamble and I cannot understand why notoccite does not work (i.e. LaTeX stills considers the references in the list of Figures/Tables as the firsts appearing in the document). Could it be something related to hyperref? I can't figure it out! Thank you in advance

% **************************************************
% Document Class Definition
% **************************************************
\documentclass[%
    %paper=A4,                  % paper size --> A4 is default in Germany
    paperheight=24cm,           % Size of a book
    paperwidth=17cm,
    twoside=true,               % true onesite or twoside printing
    openright,                  % doublepage cleaning ends up right side
    %parskip=small,             % spacing value / method for paragraphs
    chapterprefix=true,         % prefix for chapter marks
    12pt,                       % font size
    headings=normal,            % size of headings
    bibliography=totoc,         % include bib in toc totoc
    listof=nottoc,              % include listof entries in toc
    titlepage=on,               % own page for each title page
    captions=tableabove,        % display table captions above the float env
    draft=false,                % value for draft version
]{scrreprt}%

%% MISCELANEOUS
\usepackage{notoccite}
\usepackage{lmodern,textcomp}
% babel system, adjust the language of the content
\usepackage[english]{babel}     
\usepackage{enumerate} 
\usepackage{siunitx}
\usepackage{mathptmx} %ecuaciones con misma letra que texto
%% Use the following command to allow font sizes larger than `Huge'. Useful for doing the title larger
\newcommand\SuperHuge{\fontsize{40}{40}\selectfont} % For cover page
\newcommand\SuperHuuge{\fontsize{31}{31}\selectfont}% For page after cover
%% Use the parskip package to control the space between paragraphs. The following command will leave one empty line of space and will remove the identation. The space can be controlled by changing the value in the second {}.
\setlength{\parskip}{0.5\baselineskip}
\usepackage[                    % clean thesis style package and options. You can find all options in `doc' folder. These options can also be defined at the document options
    figuresep=colon, % This determines what appears after the number of the figure caption. Options are: 'colon' (inserts :), 'none' (inserts nothing), 'period' (inserts .), 'space' (inserts a single space), `quad` (inserts a larger space), 'endash' (inserts a -). 
    %sansserif=false, % Option to use sanserif font. Options are: 'true' or 'false'. This is no longer used since times font is enforced.
    hangfigurecaption=false, %Sets whether to use a hanging figure label or not (placed in page margin). Options: 'true' or 'false'.
    hangsection=true, %Sets whether to use a hanging section label (placed in page margin). Options are 'true' or 'false'
    hangsubsection=true, %Sets whether to use a hanging subsection label (placed in page margin). Options are 'true' or 'false'
    colorize=full, %This determines how many things are colored 8such as the titles, etc.). Options are: 'full' (footers, headers, sections are painted everywhere), 'reduced' (less things are painted), and 'bw' (all is black-grey color except figures).
    colortheme=blueblack, %This changes the colors of sections, titles, headers, etc. Combinations are: 'bluemagenta', 'bluegreen', 'blueblack' (added by Jose).
    bibfile=library, %Put the name of the bibliography file
    %bibsys=bibtex,%
    %bibstyle=numeric-comp %authoryear,%alphabetic,%numeric, numeric-comp
]{cleanthesis}
\usepackage{enumitem}
\usepackage{placeins}
%% Use the package `pdfpages' to include given pdf documents into your generated document
\usepackage{pdfpages}
%% Use package `threeparttable' to pro­vides a scheme for ta­bles that have a struc­tured note sec­tion, af­ter the cap­tion.
\usepackage{threeparttable}
%% Use package `pifont' for providing commands for pi fonts. See http://ctan.org/pkg/pifont
\usepackage{pifont}
%% Use package `lscape' for placing selected parts of a document in landscape
\usepackage{lscape}
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
%% Use package `changes' to show produced changes into your document
\usepackage[final]{changes}
%% The package hyperref is used to generate hyperreferences along the document. Setup it according to clean-thesis style:
\hypersetup{                    
    pdftitle={\thesisTitle},    %   - title (PDF meta)
    pdfsubject={\thesisSubject},%   - subject (PDF meta)
    pdfauthor={\thesisName},    %   - author (PDF meta)
    plainpages=false,           %   -
    colorlinks=false,           %   - colorize links?
    pdfborder={0 0 0},          %   - {0 0 0}
    breaklinks=true,            %   - allow line break inside links
    bookmarksnumbered=true,     %
    bookmarksopen=true          %
}
\usepackage{graphics}
%% or use the graphicx package for more complicated commands:
\usepackage{graphicx}
%% MATHEMATICAL PACKAGES
\usepackage{amssymb} %provides various useful mathematical symbols
\usepackage{amsthm} %provides extended theorem environments
\usepackage{amsfonts} %provides extended fonts
\usepackage{amsmath} %provides mathematical facilities
\usepackage{mathtools} %provides useful tools for mathematical typesetting
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}
\usepackage{bm} %Allows bold math font
\usepackage{gensymb} %Adds generics symbols
\usepackage[nodots]{numcompress}
\usepackage{adjustbox}
%% The cleveref package allows to compres multiple refenced equations:
\usepackage{cleveref}
\newcommand{\crefrangeconjunction}{--} %Changes "to" by "-" when referencing multiple equations, i.e. (1) to (5) becomes (1)-(5).
\crefname{equation}{}{} %This option allows that only the equation numbers appear when using the package. 
%% Clean style thesis does not number `subsubsection' by default. Add the following code so that they are numbered, and follow the same style as section and subsection:
\usepackage{titlesec}
\makeatletter
\setcounter{secnumdepth}{3}
\titlespacing{\subsubsection}{0em}{0.5em}{-0.25\baselineskip}%[0pt]
\ifct@cthesis@hangsubsection
\titleformat{\subsubsection}[hang]%
{\usekomafont{subsubsection}}%
{\color{ctcolorblack}\thesubsubsection\hspace*{10pt}}%
{0pt}%
{\raggedright}%
[\phantomsection]
\else
\titleformat{\subsubsection}[block]%
{\usekomafont{subsubsection}}%
{\color{ctcolorblack}\thesubsubsection\hspace*{10pt}}%
{0pt}%
{\raggedright}%
[\phantomsection]
\fi
\makeatother
%Change also the spacing of the section, subsection, etc, by deleting the empty line left below with:
\titlespacing{\section}{0pt}{0pt}{-0.25\baselineskip}
\titlespacing{\subsection}{0pt}{0pt}{-0.25\baselineskip}
%% By default, latex leaves a large space between the text and equations. Use the following to reduce it:
\makeatletter
\g@addto@macro\normalsize{%
    \setlength\abovedisplayskip{5pt}
    \setlength\belowdisplayskip{5pt}
    \setlength\abovedisplayshortskip{5pt}
    \setlength\belowdisplayshortskip{5pt}
}
\makeatother
%% Use the package caption or subcaption to customize the caption in figures and tables:
\usepackage{caption}
\usepackage{subcaption}
\usepackage[numbers, square, comma, sort&compress]{natbib}
%% Use the following commando to change how latex decides if a word is pushed to the next line earlier or not. It helps to avoid having words exceeding the page width
\setlength{\emergencystretch}{2pt}
%% Use the following commands to change the space between the text and figures
\setlength{\intextsep}{0.5\baselineskip plus 0.0\baselineskip minus 0.0\baselineskip} %This changes the space betwen figure and text for a figure placed at top or bottom of a page
%\setlength{\textfloatsep}{10 pt plus 0pt minus 0pt} 
\setlength{\textfloatsep}{0.5\baselineskip plus 0.0\baselineskip minus 0.0\baselineskip} %This changes the space between figure and text for a figure placed in any other place of the document.
%
% **************************************************
% ToC, LoF, LoT
% **************************************************
%
% -- modifications regarding the table of contents,
%    the list of figures and the list of tables

% The tocloft package enables us to control the typographic design of the
% table of contents, list of figures and list of tables
\usepackage{tocloft}
%
% > adjusts the indention for figure and table entries (lof and lot)
%   -- \cftsetindents{entry}{indent}{numwidth} sets the entry's indent to
%      the length indent and its numwidth to the length numwidth
\cftsetindents{figure}{0em}{3em}
\cftsetindents{table}{0em}{3em}
\renewcommand{\cfttoctitlefont}{\normalfont\huge\bfseries} %To customizethe Contents title. In this case, to use the normal font and bold.
\renewcommand{\cftpartfont}{\normalfont\sffamily\bfseries}% \part font in ToC
\renewcommand{\cftchapfont}{\normalfont\large\bfseries}    % \chapter fontin ToC
%\renewcommand{\cftsecfont}{\normalfont\slshape}           % \section fontin ToC
%\renewcommand{\cftsubsecfont}{\normalfont\itshape}        % \subsectionfont in ToC
%\renewcommand{\cftsubsubsecfont}{\normalfont\small}       %\subsubsection font in ToC
\renewcommand{\cftloftitlefont}{\normalfont\huge\bfseries} %To customizethe List of Figures title. In this case, to use the normal font and bold.
\renewcommand{\cftlottitlefont}{\normalfont\huge\bfseries} %To customizethe List of Figures title. In this case, to use the normal font and bold.

\begin{filecontents}{\jobname.bib}
    @misc{foo,
        author = {Foo},
        title = {Title of Foo},
    }
    @misc{bar,
        author = {Bar},
        title = {Title of Bar},
    }
    @misc{ba,
        author = {Ba},
        title = {Title of Ba},
    }
\end{filecontents}

% **************************************************
% Document CONTENT
% **************************************************
\begin{document}



\listoffigures

this is the text \cite{foo} and it should be cited first \cite{bar}
\begin{figure} [h]
    \centering
    \includegraphics[width=4cm]{example-image}
    \caption{the caption in the text \cite{ba}}
    \label{X}
\end{figure} 

\bibliographystyle{elsarticle-num} 

\bibliography{library}

% **************************************************
\end{document}
  • 3
    Please provide a working example, and not just a preamble. – Steven B. Segletes Apr 29 '19 at 18:02
  • Thanks for the comment Steven, I provided the mwe! – Santi Apr 29 '19 at 19:53
2

Well, you have a lot of issues in your show code, some of them resulting of some missunderstanding, I guess. Please see the following list:

  1. classicthesis does it own bibliography thing with biblatex, so your used commands \bibliographystyle and \bibliography are simply wrong. Use \printbibliography instead.
  2. With your given code you need bibfile=\jobname, as package option for classicthesis.
  3. colortheme=blueblack seems to be undefined on my system, I commented that package option for classicthesis
  4. \usepackage[nodots]{numcompress} results in error, commented.
  5. \usepackage[numbers, square, comma, sort&compress]{natbib} is wrong together with biblatex, commented. Please read the documentation of classicthesis how to use natbib.
  6. Several commands thesis... undefined in \hypersetup, commented.
  7. cleverref should be called after hyperref, hyperref is called in classicthesis
  8. You got several warnings about using packages better not to use in KOMA-Script, for example fancyhdr (use \scrlayer-scrpage instead), and others resulting from the usage of classicthesis
  9. Package notoccite is relative old (2000). Do you really need it?

However, the following code compiles without error on my current MiKTeX 2.9:

\documentclass[%
    %paper=A4,                  % paper size --> A4 is default in Germany
    paperheight=24cm,           % Size of a book
    paperwidth=17cm,
    twoside=true,               % true onesite or twoside printing
    openright,                  % doublepage cleaning ends up right side
    %parskip=small,             % spacing value / method for paragraphs
    chapterprefix=true,         % prefix for chapter marks
    12pt,                       % font size
    headings=normal,            % size of headings
    bibliography=totoc,         % include bib in toc totoc
    listof=nottoc,              % include listof entries in toc
    titlepage=on,               % own page for each title page
    captions=tableabove,        % display table captions above the float env
    draft=false,                % value for draft version
]{scrreprt}%

%% MISCELANEOUS
\usepackage{notoccite}
\usepackage{lmodern,textcomp}
% babel system, adjust the language of the content
\usepackage[english]{babel}     
\usepackage{enumerate} 
\usepackage{siunitx}
\usepackage{mathptmx} %ecuaciones con misma letra que texto
%% Use the following command to allow font sizes larger than `Huge'. Useful for doing the title larger
\newcommand\SuperHuge{\fontsize{40}{40}\selectfont} % For cover page
\newcommand\SuperHuuge{\fontsize{31}{31}\selectfont}% For page after cover
%% Use the parskip package to control the space between paragraphs. The following command will leave one empty line of space and will remove the identation. The space can be controlled by changing the value in the second {}.
\setlength{\parskip}{0.5\baselineskip}
\usepackage[                    % clean thesis style package and options. You can find all options in `doc' folder. These options can also be defined at the document options
    figuresep=colon, % This determines what appears after the number of the figure caption. Options are: 'colon' (inserts :), 'none' (inserts nothing), 'period' (inserts .), 'space' (inserts a single space), `quad` (inserts a larger space), 'endash' (inserts a -). 
    %sansserif=false, % Option to use sanserif font. Options are: 'true' or 'false'. This is no longer used since times font is enforced.
    hangfigurecaption=false, %Sets whether to use a hanging figure label or not (placed in page margin). Options: 'true' or 'false'.
    hangsection=true, %Sets whether to use a hanging section label (placed in page margin). Options are 'true' or 'false'
    hangsubsection=true, %Sets whether to use a hanging subsection label (placed in page margin). Options are 'true' or 'false'
    colorize=full, %This determines how many things are colored 8such as the titles, etc.). Options are: 'full' (footers, headers, sections are painted everywhere), 'reduced' (less things are painted), and 'bw' (all is black-grey color except figures).
%   colortheme=blueblack, %This changes the colors of sections, titles, headers, etc. Combinations are: 'bluemagenta', 'bluegreen', 'blueblack' (added by Jose). <===================================
    bibfile=\jobname,%, %Put the name of the bibliography file % <================================
    %bibsys=bibtex,%
    %bibstyle=numeric-comp %authoryear,%alphabetic,%numeric, numeric-comp
]{cleanthesis}
\usepackage{enumitem}
\usepackage{placeins}
%% Use the package `pdfpages' to include given pdf documents into your generated document
\usepackage{pdfpages}
%% Use package `threeparttable' to pro­vides a scheme for ta­bles that have a struc­tured note sec­tion, af­ter the cap­tion.
\usepackage{threeparttable}
%% Use package `pifont' for providing commands for pi fonts. See http://ctan.org/pkg/pifont
\usepackage{pifont}
%% Use package `lscape' for placing selected parts of a document in landscape
\usepackage{lscape}
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
%% Use package `changes' to show produced changes into your document
\usepackage[final]{changes}

%\usepackage{graphics}
%% or use the graphicx package for more complicated commands:
\usepackage{graphicx}
%% MATHEMATICAL PACKAGES
\usepackage{amssymb} %provides various useful mathematical symbols
\usepackage{amsthm} %provides extended theorem environments
\usepackage{amsfonts} %provides extended fonts
\usepackage{amsmath} %provides mathematical facilities
\usepackage{mathtools} %provides useful tools for mathematical typesetting
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}
\usepackage{bm} %Allows bold math font
\usepackage{gensymb} %Adds generics symbols
%\usepackage[nodots]{numcompress} % <=====================================
\usepackage{adjustbox}

%% Clean style thesis does not number `subsubsection' by default. Add the following code so that they are numbered, and follow the same style as section and subsection:
\usepackage{titlesec}
\makeatletter
\setcounter{secnumdepth}{3}
\titlespacing{\subsubsection}{0em}{0.5em}{-0.25\baselineskip}%[0pt]
\ifct@cthesis@hangsubsection
\titleformat{\subsubsection}[hang]%
{\usekomafont{subsubsection}}%
{\color{ctcolorblack}\thesubsubsection\hspace*{10pt}}%
{0pt}%
{\raggedright}%
[\phantomsection]
\else
\titleformat{\subsubsection}[block]%
{\usekomafont{subsubsection}}%
{\color{ctcolorblack}\thesubsubsection\hspace*{10pt}}%
{0pt}%
{\raggedright}%
[\phantomsection]
\fi
\makeatother
%Change also the spacing of the section, subsection, etc, by deleting the empty line left below with:
\titlespacing{\section}{0pt}{0pt}{-0.25\baselineskip}
\titlespacing{\subsection}{0pt}{0pt}{-0.25\baselineskip}
%% By default, latex leaves a large space between the text and equations. Use the following to reduce it:
\makeatletter
\g@addto@macro\normalsize{%
    \setlength\abovedisplayskip{5pt}
    \setlength\belowdisplayskip{5pt}
    \setlength\abovedisplayshortskip{5pt}
    \setlength\belowdisplayshortskip{5pt}
}
\makeatother
%% Use the package caption or subcaption to customize the caption in figures and tables:
\usepackage{caption}
\usepackage{subcaption}
%\usepackage[numbers, square, comma, sort&compress]{natbib} % <====== classicthesis
%% Use the following commando to change how latex decides if a word is pushed to the next line earlier or not. It helps to avoid having words exceeding the page width
\setlength{\emergencystretch}{2pt}
%% Use the following commands to change the space between the text and figures
\setlength{\intextsep}{0.5\baselineskip plus 0.0\baselineskip minus 0.0\baselineskip} %This changes the space betwen figure and text for a figure placed at top or bottom of a page
%\setlength{\textfloatsep}{10 pt plus 0pt minus 0pt} 
\setlength{\textfloatsep}{0.5\baselineskip plus 0.0\baselineskip minus 0.0\baselineskip} %This changes the space between figure and text for a figure placed in any other place of the document.
%
% **************************************************
% ToC, LoF, LoT
% **************************************************
%
% -- modifications regarding the table of contents,
%    the list of figures and the list of tables

% The tocloft package enables us to control the typographic design of the
% table of contents, list of figures and list of tables
\usepackage{tocloft}
%
% > adjusts the indention for figure and table entries (lof and lot)
%   -- \cftsetindents{entry}{indent}{numwidth} sets the entry's indent to
%      the length indent and its numwidth to the length numwidth
\cftsetindents{figure}{0em}{3em}
\cftsetindents{table}{0em}{3em}
\renewcommand{\cfttoctitlefont}{\normalfont\huge\bfseries} %To customizethe Contents title. In this case, to use the normal font and bold.
\renewcommand{\cftpartfont}{\normalfont\sffamily\bfseries}% \part font in ToC
\renewcommand{\cftchapfont}{\normalfont\large\bfseries}    % \chapter fontin ToC
%\renewcommand{\cftsecfont}{\normalfont\slshape}           % \section fontin ToC
%\renewcommand{\cftsubsecfont}{\normalfont\itshape}        % \subsectionfont in ToC
%\renewcommand{\cftsubsubsecfont}{\normalfont\small}       %\subsubsection font in ToC
\renewcommand{\cftloftitlefont}{\normalfont\huge\bfseries} %To customizethe List of Figures title. In this case, to use the normal font and bold.
\renewcommand{\cftlottitlefont}{\normalfont\huge\bfseries} %To customizethe List of Figures title. In this case, to use the normal font and bold.



%% The cleveref package allows to compres multiple refenced equations:
\usepackage{cleveref}
\newcommand{\crefrangeconjunction}{--} %Changes "to" by "-" when referencing multiple equations, i.e. (1) to (5) becomes (1)-(5).
\crefname{equation}{}{} %This option allows that only the equation numbers appear when using the package. 

%% The package hyperref is used to generate hyperreferences along the document. Setup it according to clean-thesis style:
\hypersetup{                    
%   pdftitle={\ThesisTitle},    %   - title (PDF meta) <================================
%   pdfsubject={\thesisSubject},%   - subject (PDF meta)
%   pdfauthor={\thesisName},    %   - author (PDF meta)
    plainpages=false,           %   -
    colorlinks=false,           %   - colorize links?
    pdfborder={0 0 0},          %   - {0 0 0}
    breaklinks=true,            %   - allow line break inside links
    bookmarksnumbered=true,     %
    bookmarksopen=true          %
}

\begin{filecontents}{\jobname.bib}
    @misc{foo,
        author = {Foo},
        title = {Title of Foo},
    }
    @misc{bar,
        author = {Bar},
        title = {Title of Bar},
    }
    @misc{ba,
        author = {Ba},
        title = {Title of Ba},
    }
\end{filecontents}



% **************************************************
% Document CONTENT
% **************************************************
\begin{document}

\listoffigures

this is the text \cite{foo} and it should be cited first \cite{bar}

\begin{figure} [h]
    \centering
    \includegraphics[width=4cm]{example-image}
    \caption{the caption in the text \cite{bar}}
    \label{X}
\end{figure} 

%\bibliographystyle{elsarticle-num} % <=================================

\printbibliography%{\jobname} % <=======================================

% **************************************************
\end{document}

with the result:

page 1

and

bibliography

  • Solved now, thank you very much! - just a bit of reordering and it works. – Santi Apr 30 '19 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.