Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Can thebibliography be sorted by citation order? Or is there a solution with an inlined bibliography that can be sorted?

Not having an additional .bib file would be preferable.

My current bilbiography is inluded in the rest of the article inside a thebibliography block.

\begin{document}
\section{Example}
The citations in\cite{ne} the bibliography should\cite{flowers} be ordered 
according which order they appear in the text. 

\begin{thebibliography}{9}

\bibitem{fetebok} \emph{Internal Combustion Engine Fundamentals}

\bibitem{ne} \emph{Förbränningsmotorer}

\bibitem{flowers} \emph{HCCI Research Towards Development for Stationary Power 
Applications}

\end{thebibliography}

Should output:

The citations in[1] the bibliography should[2] be ordered 
according which order they appear in the text. 

Bilbiography
[1] Förbränningsmotorer
[2] HCCI Research Towards Development for Stationary Power Applications
[3] Internal Combustion Engine Fundamentals
share|improve this question
    
Welcome to tex.sx! It's not necessary to sign your questions (as there is already a box with your username below it) or to begin them with a greeting. –  Joseph Wright May 4 '11 at 9:41
5  
The standard unsrt style does exactly this: a minimal example of your code would be very useful to give a more targeted answer. –  Joseph Wright May 4 '11 at 9:42
2  
This is a duplicate of tex.stackexchange.com/questions/14976/…. This qn is a bit more clearly phrased and easier to find than the older qn, so it might be an idea to close the older one as a duplicate of this one. –  Charles Stewart May 4 '11 at 10:48
    
\bibliographystyle{unsrt} doesn't seem to work with \begin{thebibliography}. Nothing is changing anyway. –  Robert Foss May 4 '11 at 17:10
1  
You might need to delete your .aux and .bbl files before it will work properly... –  Seamus May 4 '11 at 17:13

2 Answers 2

up vote 9 down vote accepted

If you really need a bibliography sorted by citation order you have two choices:

(1) write the entries in thebibliography in citation order

(2) use a .bib file, \bibliographystyle{unsrt} and BibTeX.

There is a third choice, actually, but I did it just to prove it's possible:

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}

\newcounter{mycite}
\newtoks\citetoks
\makeatletter
\DeclareRobustCommand\unscite[1]{%
  \@ifundefined{uns@cite#1}
    {\refstepcounter{mycite}\label{citelabel@#1}%
     \expandafter\xdef\csname uns@cite#1\endcsname{\arabic{mycite}}%
     \toks\z@=\expandafter{\the\citetoks}%
     \toks\tw@=\expandafter\expandafter\expandafter{%
       \csname uns@bibitem#1\endcsname}%
     \edef\@tempcite{\the\toks\z@\the\toks\tw@}%
     \global\citetoks=\expandafter{\@tempcite}%
    }{}[\@nameuse{uns@cite#1}]}
\newcommand{\mybibitem}[2]{%
  \@namedef{uns@bibitem#1}{\bibitem[\ref{citelabel@#1}]{#1}#2}}
\makeatother


% Define here the bibliography entries
\mybibitem{fetebok}{\emph{Internal Combustion Engine Fundamentals}}
\mybibitem{ne}{\emph{Förbränningsmotorer}}
\mybibitem{flowers}{\emph{HCCI Research Towards Development for Stationary 
  Power Applications}}

\begin{document}
\section{Example}
The citations in~\unscite{ne} the bibliography should~\unscite{flowers}
be ordered according which order they appear in the text. 

\begin{thebibliography}{\arabic{mycite}}
\the\citetoks
\end{thebibliography}

\end{document}

Notice that this \unscite can't process lists of references or the optional argument like the usual \cite. It might be done, but I advise you against this approach.

share|improve this answer

Yes there is a way to sort \bibitems in the order order of appearance in the text. Have a look at https://code.google.com/p/latex-bibitemstyler/, a nice little program that does this job like a charm.

share|improve this answer
    
This a duplicate answer. See Is it acceptable to add a duplicate answer to several questions? for why this should be avoided and how to provide better answers. –  Andrew Swann Nov 15 '13 at 10:38
    
Thank you for pointing this out to me (newbie). I adjusted the answers (same solution for different questions). –  Günther Nov 15 '13 at 11:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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