LyXnatbib | Citation Numbering by Appearance

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
_Chronos_
Posts: 3
Joined: Thu Jun 14, 2012 2:00 pm

natbib | Citation Numbering by Appearance

Post by _Chronos_ »

Hi,

I am writing my PhD (chemistry) with LyX (being completely new to LaTeX, I thought it would be easier).

Up to now I am totally satisfied with this software and its capabilities. From a template found on the web, I managed to do pretty much everything I wanted. Except ... the bibliography!

My thesis is divided into six chapters (in the form of sub-documents that fit into a main thesis file) so I built a bibliography with multiple file .bib for each chapter (and the option enabled in the document settings ). Each chapter is started and ended by \begin{btUnit} and \end{btUnit}, respectively, as described in the manual of advanced options. When I preview my bibliography is well managed and appears in the PDF output. So everything is fine you will tell me?!

Well not everything!! My problem concerns the numbering. I chose to use natbib numbered citations (with implicit numbering it gives me a lot of LaTeX errors...), and instead of being incremented progressively in the text, their number corresponds to their place in the reference list, which is sorted alphabetically by authors. I use the style "unsrt", which is supposed to sort the references in order of appearance, but it does not work. I actually tried a dozen styles but without success ... (and a few hours reading the forums ....)

In "Plan B" my library works with the "author-date" style but really I'd rather be able to number them, and in order!

My question is simple - would there be a kind soul to help a PhD student near the nervous breakdown? :)

Thank you!


PS: I'm not sure at all about what is important or not to mention so I await your requests!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

_Chronos_
Posts: 3
Joined: Thu Jun 14, 2012 2:00 pm

natbib | Citation Numbering by Appearance

Post by _Chronos_ »

I am becoming desperate...
I spent hours on the web but it is still not working...
I entered the code:

Code: Select all

\usepackage[sort&compress]{natbib}
\setcitestyle{numbers}
\citestyle{nature}
\bibliographystyle{unsrtnat}
in the preamble of lyx, the bibliography is well managed in the "Nature" style (with numbers in superscript) but they are still not in the order of citation......
unsrtnat is not supposed to do so?? :cry:
_Chronos_
Posts: 3
Joined: Thu Jun 14, 2012 2:00 pm

natbib | Citation Numbering by Appearance

Post by _Chronos_ »

Hi,

I still didn't find the solution...

Here is the Latex source of my document from Lyx, perhaps the problem is coming from a mistake in the document class?

Code: Select all

%% LyX 2.0.3 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[oneside,english,french]{thl3i}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\setcounter{secnumdepth}{1}
\setcounter{tocdepth}{1}
\usepackage{array}
\usepackage{float}
\usepackage{textcomp}
\usepackage{multirow}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage[dot]{bibtopic}
\PassOptionsToPackage{normalem}{ulem}
\usepackage{ulem}
\onehalfspacing

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\DeclareRobustCommand{\greektext}{%
  \fontencoding{LGR}\selectfont\def\encodingdefault{LGR}}
\DeclareRobustCommand{\textgreek}[1]{\leavevmode{\greektext #1}}
\DeclareFontEncoding{LGR}{}{}
\DeclareTextSymbol{\~}{LGR}{126}
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}
%% A simple dot to overcome graphicx limitations
\newcommand{\lyxdot}{.}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\numberwithin{equation}{section}
\newcommand{\lyxaddress}[1]{
\par {\raggedright #1
\vspace{1.4em}
\noindent\par}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage[numbers,super,sort&compress]{natbib}
\bibliographystyle{unsrtnat}

\makeatother

\usepackage{babel}
\addto\extrasfrench{%
   \providecommand{\og}{\leavevmode\flqq~}%
   \providecommand{\fg}{\ifdim\lastskip>\z@\unskip\fi~\frqq}%
}

\begin{document}

\titreLogoUn{}


\titreLogoDeux{}


\subject{}


\title{}


\author{\textbf{\large }\\
}


\date{xx/xx/2012}


\Rapporteurs{Rapporteur 1&Université 1\\
Rapporteur 2&Université 2}


\Examinateurs{Examinateur 1&Université 3\\
Examinateur 2&Université 4}


\Directeur{Directeur 1&Université 5}


\Encadrant{Encadrant 1&Université 6}


\Encadrant{Invité 1&Université 7}


\titreBasDePage{}

\maketitle

\address{%
\begin{minipage}[t][1\textheight]{1\columnwidth}%
\begin{center}
\includegraphics[width=3cm]{Logos/Financeur}
\par\end{center}

\vspace{1cm}


\begin{tabular}{rll}
\emph{Thèse réalisée au} & \multicolumn{2}{l}{Institut de Chimie et des Matériaux Paris-Est}\tabularnewline
 & \multicolumn{2}{l}{}\tabularnewline
 & \multicolumn{2}{l}{}\tabularnewline
 & \multicolumn{2}{l}{}\tabularnewline
 & \multicolumn{2}{l}{}\tabularnewline
 & \multicolumn{2}{l}{}\tabularnewline
 & \multicolumn{2}{l}{}\tabularnewline
 & \multicolumn{2}{l}{}\tabularnewline
 & \multicolumn{2}{l}{Web : {}\tabularnewline
 & \multicolumn{2}{l}{}\tabularnewline
\emph{Sous la direction de } & \tabularnewline
 &  & \tabularnewline
\emph{Co-encadrement} & \tabularnewline
 &  & \tabularnewline
\end{tabular}

\begin{center}
\cleardoublepage
\par\end{center}

\begin{center}

\par\end{center}%
\end{minipage}}

\frontmatter

\include{Remerciements}\include{Résumé}

\include{Abstract}

\tableofcontents{}

\listoffigures


\listoftables


\include{abreviations}

\mainmatter

\include{Introduction}

\include{Chapitre1}

\include{Chapitre2}

\include{Chapitre3}

\include{Chapitre4}

\include{Chapitre5}

\include{Chapitre6}

\include{Conclusion}

\include{Annexes}

\backmatter
\end{document}
What i don't understand is why \usepackage[numbers,super,sort&compress]{natbib} is working but not \bibliographystyle{unsrtnat}
Or the problem can come from my bib files?

I would extremely appreciate any help.

Thanks.

_Chronos_
nina_m
Posts: 2
Joined: Mon Jan 14, 2013 4:03 pm

Re: natbib | Citation Numbering by Appearance

Post by nina_m »

Hi _Chronos_

I am trying to get the same thing (numbers in text in order of appearance and reference list sorted in the order of those numbers)

Have you managed to solve your problem?
How do you do it?
Also, I copied part of your preamble to get the nice superscripted numbers. How did you solve the situation when you want to put in the author and reference number.
I.e "Smith et al ^{1} noted that this text is useless"
Do you put in the name by hand and let lyx/bibtex handle the rest, or there is an option for that too?

Thanks!
nina
nina_m
Posts: 2
Joined: Mon Jan 14, 2013 4:03 pm

natbib | Citation Numbering by Appearance

Post by nina_m »

ok, update, (for people that will maybe stumble upon this after months, like i did on _chronos_ post. )

i am working in Lyx 2.0.

In document> setting> bibliography i put "default(numerical)" (otherwise it gives some bibliography clash error)
and then in Latex preamble I added:

\bibliographystyle{unsrtnat}
\usepackage[numbers,sort&compress]{natbib}


this sets the citations in text as numbers in order of appearance, but "jones et.al [1] mentioned that.." goes to "[1] mentioned that..".
So, only in places where I need the name, I insert LateX code and write the citation in the form of \citet{Jon1990}, which seems to work.

I am not sure if it works for superscripted numbers too, but eventually I decided that I don't really have to have that =D
tonty
Posts: 1
Joined: Fri Feb 22, 2013 7:31 am

Re: natbib | Citation Numbering by Appearance

Post by tonty »

I might be too late. But please try the psfg.bst .
clif34
Posts: 1
Joined: Wed Mar 11, 2015 5:25 am

natbib | Citation Numbering by Appearance

Post by clif34 »

Hello,

I have never done one of these before and I know this is a very late response. But I spent all day trying to solve the same problem and found a quick easy solution. I implemented:
\bibliographystyle{unsrtnat}
\usepackage[sort&compress,numbers]{natbib}


At first the citations were not in order of appearance but then I went into my folder and manually deleted my '.bbl' file. This forced a new one to be generated with the citations in order of appearance. :D

Hope this helps...someone.
ssharfst
Posts: 1
Joined: Thu Jul 02, 2015 10:52 pm

Re: natbib | Citation Numbering by Appearance

Post by ssharfst »

clif34-THANK YOU. I was having the exact same problem, deleted the bbl file and life is so much better. :D
Post Reply