## LaTeX forum ⇒ Theses, Books, Title pages ⇒ Illegal, another \bibstyle command error Topic is solved

Classicthesis, Bachelor and Master thesis, PhD, Doctoral degree
Mahmudul
Posts: 7
Joined: Mon May 25, 2020 3:27 pm

### Illegal, another \bibstyle command error

Hi for my Ph.D. thesis, I am trying to compile several chapters into one main file (report). I am also trying to have separate appendixes and references for each chapter instead of having one big appendix and reference end of the report. For reference, I am using the following command end of each chapter

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})\bibliographystyle{econ}\bibliography{Reference1}

Reference1 is my master reference file. To have a separate appendix for each chapter, I have used the subappendices option. Appen1 and Appen2 are the appendix files for each chapter. Here is the code for the main file :

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})\documentclass[12pt,a4paper,english]{report}\usepackage[T1]{fontenc}\usepackage[utf8]{inputenc}\usepackage{babel}\usepackage{appendix}\usepackage{blindtext}\usepackage{amsmath, epsfig,graphicx,mathrsfs}\usepackage{float}\usepackage{ltablex,booktabs}\usepackage{array}\usepackage{multirow}\usepackage{longtable}\usepackage[tableposition=below]{caption}\usepackage{caption}\usepackage{subcaption}\usepackage{natbib}\usepackage{url}\usepackage{chapterbib}\usepackage[framed, numbered]{matlab-prettifier}\usepackage[stable]{footmisc}\usepackage[nottoc]{tocbibind} \begin{document} \tableofcontents \listoffigures \listoftables \include{Chapter1}   \begin{subappendices} \include{Appen1} \end{subappendices}  \include{Chapter2}  \begin{subappendices} \include{Appen2} \end{subappendices} \end{document}

Now I am getting the following error :

Process started: bibtex.exe "FullThesis"

This is BibTeX, Version 0.99d (MiKTeX 2.9.6630 64-bit)
The top-level auxiliary file: FullThesis.aux
A level-1 auxiliary file: Chapter1.aux
The style file: econ.bst
A level-1 auxiliary file: Appen1.aux
A level-1 auxiliary file: Chapter2.aux
Illegal, another \bibstyle command---line 73 of file Chapter2.aux
: \bibstyle
: {econ}
I'm skipping whatever remains of this command
Illegal, another \bibdata command---line 74 of file Chapter2.aux
: \bibdata
: {Reference1}
I'm skipping whatever remains of this command
A level-1 auxiliary file: Appen2.aux
Database file #1: Reference1.bib
Warning--there is no volume, number, and pages in lyden2001empirical
(There were 2 error messages)

Process exited with error(s)

Process started: pdflatex.exe -synctex=1 -interaction=nonstopmode "FullThesis".tex

Process exited normally

Can somebody help me with this error? It seems that despite the given error, a PDF file has been produced by the Latex, where Appendix and References, etc. are placed exactly where I wanted.

NOTE: If I run each chapter separately as an article using the same bib style and references, I never get any error. It runs perfectly.

rais
Posts: 268
Joined: Sun Nov 16, 2014 8:51 pm
Mahmudul wrote:For reference, I am using the following command end of each chapter

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})\bibliographystyle{econ}\bibliography{Reference1}

When it comes to \bibliographystyle, think Highlander' (there can be only one).

KR
Rainer

Mahmudul
Posts: 7
Joined: Mon May 25, 2020 3:27 pm
rais wrote:When it comes to \bibliographystyle, think Highlander' (there can be only one)

Thanks for your help. Could you please elaborate a bit more on Highlander (there can be only one)'? since I am a novice user, not much familiar with the Latex jargon.

rais
Posts: 268
Joined: Sun Nov 16, 2014 8:51 pm
As a general rule of thumb, \bibliographystyle must not be called more than once.
Since you're using chapterbib, where you actually have to provide such a \bibliographystyle in each included file where you want to have such a chapterbib, this translates roughly to do not run BibTeX on your main aux file, but on each aux file from the included files.''
So instead of calling bibtex FullThesis, you should call
bibtex Chapter1
and
bibtex Chapter2

KR
Rainer

Ijon Tichy
Posts: 282
Joined: Mon Dec 24, 2018 10:12 am
rais wrote:When it comes to \bibliographystyle, think Highlander' (there can be only one).

This is usually correct, but the OP uses chapterbib. With chapterbib each included file (only with \include not with, e.g., \input) has its own \bibliographystyle and \bibliography. See the introduction of the manual:
Donald Arseneau wrote:The main point is to allow you to use BibTEX: Each included file should have its own \bibliographystyle and \bibliography commands, and you should
run bibtex on each included file separately rather than on the main or root file.

So I think (but I do not know, because the OP has not told), the real problem was, that Mahmudul ran BibTeX with the main file instead of each included file.

@Muhmudul: Please don't run bibtex FullThesis' but:
• bibtex Chapter1
• bibtex Appen1
• bibtex Chapter2
but only for those files that have a bibliography.

If you would have posted a complete example not only some code snippets, I would have answered on wednesday already. With only some code but not a minimal working example, I needed to make my own test example this morning. So I needed more than 30 minutes to test and answer (and that's the reason for having now, two times the almost same answer).

BTW: Because most editors do not support multiple runs of bibtex for several files of one document, it could be easier to use biblatex + biber for multiple bibliographies on one document (at least as long a you need only one style for all of them). This combination does need only one biber run (instead of the bibtex run). So the usual "Run BibTeX" feature of most LaTeX editors is enough and you don't need to use either the command line or tools like arara to handle multiple runs of BibTeX.

Mahmudul
Posts: 7
Joined: Mon May 25, 2020 3:27 pm
rais wrote:So instead of calling bibtex FullThesis, you should call
bibtex Chapter1
and
bibtex Chapter2
Rainer

@Muhmudul: Please don't run bibtex FullThesis' but:
bibtex Chapter1
bibtex Appen1
bibtex Chapter2

but only for those files that have a bibliography.

Thanks a lot, @rais and @Ijon Tichy for your kind help. That was my first post in this forum, I hope to make sure to ask the question more efficiently next time and sorry for that @Ijon Tichy. I have separate references for chapter1 and chapater2 that is why using chapterbib.

I did compile the Chapter1.aux and Chapter2.aux bibliography separately after running the main file FullThesis. I have followed the instruction on chapterbib given in https://www.youtube.com/watch?v=DDwrwJzQhIU. Here is the message
Process started: bibtex.exe "Chapter1"

This is BibTeX, Version 0.99d (MiKTeX 2.9.6630 64-bit)
The top-level auxiliary file: Chapter1.aux
The style file: econ.bst
Database file #1: Reference1.bib
Warning--there is no volume, number, and pages in lyden2001empirical
(There was 1 warning)

Process exited normally

Process started: bibtex.exe "Chapter2"

This is BibTeX, Version 0.99d (MiKTeX 2.9.6630 64-bit)
The top-level auxiliary file: Chapter2.aux
The style file: econ.bst
Database file #1: Reference2.bib

Process exited normally

The Good thing is that now I can see all the references appear exactly.

However, When I run the main file, despite producing the correct PDF file, still getting the following message. First, it said
Process exited with error(s)
and again
Process exited normally
. Here is the full message:

Process started: bibtex.exe "FullThesis"
This is BibTeX, Version 0.99d (MiKTeX 2.9.6630 64-bit)
The top-level auxiliary file: FullThesis.aux
A level-1 auxiliary file: Chapter1.aux
The style file: econ.bst
A level-1 auxiliary file: Appen1.aux
A level-1 auxiliary file: Chapter2.aux
Illegal, another \bibstyle command---line 73 of file Chapter2.aux
: \bibstyle
: {econ}
I'm skipping whatever remains of this command
Illegal, another \bibdata command---line 74 of file Chapter2.aux
: \bibdata
: {Reference2}
I'm skipping whatever remains of this command
A level-1 auxiliary file: Appen2.aux
Database file #1: Reference1.bib
Warning--there is no volume, number, and pages in lyden2001empirical
(There were 2 error messages)
Process exited with error(s)
Process started: pdflatex.exe -synctex=1 -interaction=nonstopmode "FullThesis".tex
Process exited normally

I am wondering if I have followed your instruction correctly.
I have followed the instruction on chapterbib given in https://www.youtube.com/watch?v=DDwrwJzQhIU.

If not, is there any video tutorial to follow the instruction?

Thanks a lot again for your kind help and bear with me..

Ijon Tichy
Posts: 282
Joined: Mon Dec 24, 2018 10:12 am
Mahmudul wrote:[
This is BibTeX, Version 0.99d (MiKTeX 2.9.6630 64-bit)
The top-level auxiliary file: FullThesis.aux

You've once again done a BibTeX run for the main file. Don't do it! chapterbib does not support BiBTeX runs for the main file only for the included files. For the main file you should run PDFLaTeX, LuaLaTeX or XeLaTeX only, but not BibTeX! If your editor automatically runs BibTeX by default, deactivate this step or call the proper LaTeX command on the terminal instead from editor menu, toolbar or shortcut key.

If you need an additional main bibliography you cannot use chapterbib. biblatex would support multiple bibliographies without the need of \include. So you with biblatex you could have an additional bibliography for the main file. But not with chapterbib.

BTW: I've not watched or analyzed this YouTube videos, but most LaTeX YouTube videos are outdated, made by LaTeX novices, that tell a lot of nonsense, and are not really recommended. And even some of my comments to faults in YouTube LaTeX tutorials have been deleted. So I think, it is stolen time, to watch and analyze those videos. Sorry.

Mahmudul
Posts: 7
Joined: Mon May 25, 2020 3:27 pm
For the main file you should run PDFLaTeX, LuaLaTeX or XeLaTeX only, but not BibTeX! If your editor automatically runs BibTeX by default, deactivate this step or call the proper LaTeX command on the terminal instead from the editor menu, toolbar, or shortcut key.

Thanks again! I was using TexStudio. For some reason, even if run PDFLaTeX still getting the same error. Now I have changed to TexMaker. Using TexMaker PDFLaTeX runs without error!
Thanks again @ Ijon Tichy!