Text FormattingHELP: Inconsistency using \bibitem{} vs. \bibitem[]{}

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
butsam
Posts: 5
Joined: Tue Mar 17, 2015 6:46 pm

HELP: Inconsistency using \bibitem{} vs. \bibitem[]{}

Post by butsam »

I am using MiKTeX 2.9 Package Manager on Windows 8.1 to produce a document (all packages are up-to-date). I have a strange situation where, for some reason, the following two commands are giving different results:

Code: Select all

\bibitem{Key} Lastname, Firstname. "Article", Journal, Vol. pages
This results in:

1. Lastname, Firstname. "Article", Journal, Vol. pages

If instead I use:

Code: Select all

\bibitem[1]{Key} Lastname, Firstname. "Article", Journal, Vol. pages
This results in:

[1] Lastname, Firstname. "Article", Journal, Vol. pages

I want the format to appear as the latter (bracketed numbers in the bibliography), but I don't want to have to manually enter in each number--I want bibitem to keep track of which number it is assigning to each reference. Online, I see people claiming [] is the default, but it certainly does NOT appear that way!

I am using the spie.cls style file, available here: http://kmh-lanl.hansonhub.com/spie/spie.cls

In particular, what to me seems like the relevant snippet in the spie.cls style file defines the bibliography as follows:

Code: Select all

%%%% references %%%%
% Give the references section a section number
\def\thebibliography#1{\section*{REFERENCES\@mkboth
 {REFERENCES}{REFERENCES}}\list
 {[{\hskip .02em}\arabic{enumi}{\hskip .05em}]}
 {\settowidth\labelwidth{[#1]}\leftmargin\labelwidth
 \advance\leftmargin\labelsep \usecounter{enumi}}
 \def\newblock{\hskip .11em plus .33em minus .07em}
 %% reduce vspace between items
  \parskip -0.7ex plus 0.5ex minus 0ex   
\if0\@ptsize\else\small\fi      %% smaller fonts
 \sloppy\clubpenalty4000\widowpenalty4000
 \sfcode`\.=1000\relax}
\let\endthebibliography=\endlist
I don't know enough about style files and thebibliography to know what is causing this inconsistency...how do I go about fixing it?

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

HELP: Inconsistency using \bibitem{} vs. \bibitem[]{}

Post by Johannes_B »

The appearance of the bibliography is either done by hand, which is your case, or for the lazy (efficient) people by software. In the old days, and many publishers still keep their workflow, the appearance of the bibliography was handled using style files in a strange format, quite hard to change even for experienced users. The helper program BibTeX is used to sort the bibliography.

SPIE provides such a file, called spiebib.bst. Please use it in accordance with their style requirements.

Code: Select all

\documentclass{spie}
\begin{document}
\cite{companion}\par
\cite{aristotle:physics}

\bibliographystyle{spiebib}
\bibliography{biblatex-examples.bib}
\end{document}

All people who have the freedom to choose, use the modern combo of biblatex and biber to deal with bibliographies.



You can find quite a lot about this stuff reading Nicola Talbots works, one chapter in LaTeX for complete novices and one or two in Using LaTeX to write a PhD thesis.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
butsam
Posts: 5
Joined: Tue Mar 17, 2015 6:46 pm

HELP: Inconsistency using \bibitem{} vs. \bibitem[]{}

Post by butsam »

I am actually using BibTeX, but I tried pasting the output of the .bbl file into my .tex file in thebibliography to see if the problem was with the .bbl file or with the .cls file (or somewhere else). BibTeX generates the following (for the first two entries):

Code: Select all

\bibitem{Schott09}
Schott, J.~R.,  [{\em Fundamentals of Polarimetric Remote
  Sensing}{\nolinebreak\hspace{0.1em}]}, SPIE (2009).

\bibitem{Eismann12}
Eismann, M.~T.,  [{\em Hyperspectral Remote
  Sensing}{\nolinebreak\hspace{0.1em}]}, SPIE Press (2012).
If I use BibTeX, it produces "1." output instead of "[1]" output. If I use thebibliography environment with that same entry, it does similarly. If I manually use \bibitem[1]{Schott09} ... and \bibitem[2]{Eismann12} ..., it prints out correctly...but it is a pain to do so.

If it is possible to use the SPIE bibliography style in conjunction with BibLaTeX, though, I am all ears!
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

HELP: Inconsistency using \bibitem{} vs. \bibitem[]{}

Post by Johannes_B »

Please run the example i have given you above, what do you get?


biblatex works on a completely different level. You cannot use it with classical bst-files. The class file also requires usage of package cite, which is incompatible.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
butsam
Posts: 5
Joined: Tue Mar 17, 2015 6:46 pm

HELP: Inconsistency using \bibitem{} vs. \bibitem[]{}

Post by butsam »

I think I have traced the problem to this...

I had the spiebib.bst and spie.cls files in the parent directory, and had:

Code: Select all

\documentclass{../spie}

% I had my text here

\bibliographystyle{../spiebib}
\bibliography{../mybibliography}
For some reason, that changed the numbering format of the bibliography. If I copied the spiebib.bst file into the same directory and took out the ../, then it gave me square brackets []. (I still kept mybibliography in the parent directory, which worked fine.)

Not sure why there is a difference, but I will be sure to just copy the spiebib.bst and the spie.cls to the same directory! (Or is there another solution to put these in some MikTeX directory where they will always be visible and used properly? Is it possible that maybe MikTeX was finding an old version of spie.cls and/or spiebib.bst perhaps? I don't know where it looks for these class definitions by default...)
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

HELP: Inconsistency using \bibitem{} vs. \bibitem[]{}

Post by Johannes_B »

There is a pretty good answer to where to put custom class and bib-files at TeX.SX.

The log-file of your LaTeX runs shows which files are opened. You can have a closer look at it, to find out which file exactly is used.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
butsam
Posts: 5
Joined: Tue Mar 17, 2015 6:46 pm

Re: HELP: Inconsistency using \bibitem{} vs. \bibitem[]{}

Post by butsam »

I am pretty sure it is pulling an old spie.cls file now, with that knowledge. Here is the output from the log:

Document Class: spie 2007/04/14 v3.25 SPIE Proceedings class

The spie.cls file I am using is labeled as v3.30.

I now know from the path in the log file where to put the new spie.cls definition for my own computer, but how would I go about submitting this latest spie.cls file to MikTeX so it will update the package in the repository, so others aren't plagued by the same issue (including me on computers where I don't have admin privileges)?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: HELP: Inconsistency using \bibitem{} vs. \bibitem[]{}

Post by Johannes_B »

You cannot change the MikteX repositories. You can ask the SPIE guys to upload the class and bst to CTAN, the central station to put stuff like that. The two big distributions TeX Live and MikTeX take all the stuff from there, if the license is ok.

LaTeX looks for files in the current working directory first, you can always put custom classes there. What other users do on their machine, you can hardly influence.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
butsam
Posts: 5
Joined: Tue Mar 17, 2015 6:46 pm

Re: HELP: Inconsistency using \bibitem{} vs. \bibitem[]{}

Post by butsam »

Thank you, I will see if I can get them to upload it on CTAN to update the style.

You have been very helpful, much appreciated!
Post Reply