Compiling LaTex bib source - latex

I am writing my thesis in Latex, and I have the references in an own thesis.bib
file which look as follows
#Article{xxx,
author = "D.A. Reinhard",
title = "Case Study",
year = "1985",
}
and I reference them in my main document as ~\cite{xxx}
When I compile then the main document with: pdflatex main.tex than
it shows me question marks instead of the proper references to the bibliography.
Do I also need to compile the bib source on its own? If yes, can somebody please
tell me the command for Linux
Many thanks!

You need to compile the bibtex file.
Suppose you have article.tex and article.bib. You need to run:
latex article.tex (this will generate a document with question marks in place of unknown references)
bibtex article (this will parse all the .bib files that were included in the article and generate metainformation regarding references)
latex article.tex (this will generate document with all the references in the correct places)
latex article.tex (just in case if adding references broke page numbering somewhere)

You have to run 'bibtex':
latex paper.tex
bibtex paper
latex paper.tex
latex paper.tex
dvipdf paper.dvi

I am using texmaker as the editor.
you have to compile it in terminal as following:
pdflatex filename (with or without extensions)
bibtex filename (without extensions)
pdflatex filename (with or without extensions)
pdflatex filename (with or without extensions)
but sometimes, when you use \citep{}, the names of the references don't show up. In this case, I had to open the references.bib file , so that texmaker could capture the references from the references.bib file. After every edition of the bib file, I had to close and reopen it!! So that texmaker could capture the content of new .bbl file each time. But remember, you have to also run your code in texmaker too.

Just in case it helps someone, since these questions (and answers) helped me really much; I decided to create an alias that runs these 4 commands in a row:
Just add the following line to your ~/.bashrc file (modify the main keyword accordingly to the name of your .tex and .bib files)
alias texbib = 'pdflatex main.tex && bibtex main && pdflatex main.tex && pdflatex main.tex'
And now, by just executing the texbib command (alias), all these commands will be executed sequentially.

Related

adding latex packages to doxygen can not work

I want to add some graphics to my doxygen generated output. For that I need to add some more packages:
\usepackage{tikz}
\usepackage{tikz-timing}
\usetikzlibrary{mindmap}
\usetikzlibrary{arrows,shadows}
The first two lines can be added to the Doxyfile with
EXTRA_PACKAGES = {tikz} \
{tikz-qtree}
But the 2 other ones are not.
Is there a chance to add a .tex file into the generated output files before pdflatex starts?
Adding
LATEX_EXTRA_STYLESHEET = packages.tex
will not work. It used my file but the output is broken. Seems that the packages are loaded at the wrong place or time.
The third thing i tried was writing a header file with
doxygen -w latex ....
This works and changing the header.tex file is ok, but this ends up in always in generating the header, patching the header, run doxygen again with own header. This is very stupid!
Any idea?
The EXTRA_PACKAGES option is equivalent to the \usepackage tag in Latex. This of course doesn't work for the \usetikzlibrary tags.
You can add your modified Latex header using the tag LATEX_HEADER in the Doxyfile, e.g.:
LATEX_HEADER = ./templates/latex/YourCustomHeader.tex
Then Doxygen pulls this Latex header file when generating the documentation. In this file you can add the used packages and libraries.
By the way: The custom stylesheet isn't used before you run the make.bat script, so it is sufficient if you copy the modified 'doxygen.sty' file to the output folder after Doxygen generated the Latex files, but before you run the 'make.bat' script to generate the PDF file. I do this by a script which first calls doxygen then copies the necessary files to the output folder and finally calls the 'make.bat' script...

Latextools does not display cite keys if .tex file is in subfolder

The wonderful LatexTools plugin for Sublime Text 2 autocompletes references when using \cite. Everything works perfectly when the .bib filed is in the same folder as the .tex file, and the .tex file includes the \bibliography command.
Unfortunately, for my larger projects, I keep my chapter .tex files in a subfolder. The \bibliography command only appears once in the master .tex file, and the .bib file lives with the master .tex file.
Is there a way to "point" LatexTools to my bibliography for all of the sub .tex files which do not include the \bibliography command, so that I can get autocomplete working?
LatexTools searches for a root file that is specified in the subfile you are editing. When it finds such a file, it will look for bibliography related commands there and load the corresponding data. You provide the root file by placing the line
%!TEX root = ../my_main_file.tex
in the (first line of the) subfile.

How to include LaTeX snippets directly in Doxygen comments?

I would like to be able to edit LaTeX parts of some Doxygen comments externally with some suitable editor. I would use that only for complex environments. To do that, I figured I can have LaTeX-only files and include them from Doxygen. I did create Doxygen aliases for \begin and \end to make the syntax compatible.
(For example, I know how to set-up Emacs/AUCTex for working with LaTeX snippets that have no preamble and document structure.)
Is there a way to include the contents of a .tex file inside a Doxygen comment? I look for something analogous to \htmlinclude, but for TeX files. Is there some way to emulate the functionality, given my requirements for having a TeX-only external source?
You may use something like
\latexonly
\input <file>
\endlatexonly
where <file> is the path to the file to include, either absolute or relative to the directory in which the latex documentation is generated.
Have you tried the \verbinclude command? This command includes any file verbatim in the documentation (in contrast to \include, which is used to include source files).
From the doxygen manual:
\verbinclude <file-name>
This command includes the file <file-name> verbatim in the documentation. The command is equivalent to pasting the file in the documentation and placing \verbatim and \endverbatim commands around it.
Files or directories that doxygen should look for can be specified using the EXAMPLE_PATH tag of doxygen's configuration file.
Edit: I just had a thought that you may wish to strip the preamble from your .tex file before including the rest of the file in the documentation. you could do this using the \dontinclude command which, together with the \line, \skip, \skipline, and \until commands allows you to include specific lines/blocks of a particular file. See the example in the \dontinclude documentation.

How to load latex .sty files from a subdirectory?

I use some .sty-files that are not part of texlive and want to have them in a subdirectory of the folder with my main.tex. I used the following line to load the package:
\usepackage{sty/prettythesis}
This works, but compiling the main.tex with xelatex and using rubber gives me a warning:
sty/prettythesis.sty: You have requested package `sty/prettythesis',
but the package provides `prettythesis'. (page 1)
Is there a way to prevent this warning or handle this case without having to include "sty\" in all .sty-files' \ProvidesPackage command or set the TEXINPUTS environment variable (which seems not to be possible from the main.tex itself)?
I believe this thread here:
LaTeX Community • View topic - Including tex files
talks about precisely the same thing: so it seems, the only alternatives are either using TEXINPUTS environment variable; or using the import package. (note, there is a variant on the import package on ...Including tex files pg 3.)
A bit more about TEXINPUTS:
TeX Frequently Asked Questions -- “Temporary” installation of (La)TeX files
Setting TeX Environment Variable Paths
Environment Variables for Running LaTeX
TeX (and Variations) for Writing Math - math.umn.edu (see 'TeX Inputs')
Installing LaTeX packages - TeX search paths
Hope this helps;
Cheers!
EDIT: I hoped that one could set the TEXINPUTS path directly in the tex file (by using \write18 -- and note, some versions of LaTeX use --enable-write18, mine uses -shell-escape to enable \write18; see also this) - but it seems it is not possible:
"... This isn't possible. ... The environment variable of the child process is set, but this hasn't an effect to its parent process (TeX)." (Re: Setting the environmental variable TEXINPUTS within latex - comp.text.tex).
... so, now I just call pdflatex in my Linux bash like this:
TEXINPUTS=.//:$TEXINPUTS pdflatex ./myfile.tex
and then it will resolve directly \usepackage{mypackage} in the myfile.tex file - even if mypackage.sty is in a subdirectory, say ./subdir/mypackage.sty.
As you discovered, putting the package in a subdirectory (say, ./sty/prettythesis.sty with respect to your main .tex file at ./), and calling the package via
\usepackage{sty/prettythesis}
will successfully load the package, but it will produce the warning
sty/prettythesis.sty: You have requested package `sty/prettythesis',
but the package provides `prettythesis'. (page 1)
If all you want is to get rid of this warning, and you're OK with minor modifications in the .sty file, then you can simply change the package name that it reports, by changing the \ProvidesPackage command to
\ProvidesPackage{sty/prettythesis}
This can be inconvenient if you're going to be moving it around loads, but the modifications load isn't too bad either.
Even better, if what you have in there is a specific, modified version of a standard TeX package (like, say, this patch of natbib), then the change in the package name clearly indicates what package it's providing, and if you reuse the file then it will (most likely) re-raise a warning to prompt you into making sure that you know what you're doing.
You can do it in your TeX file without changing your system's environment (do not forget the trailing slash / with each directory):
\makeatletter
\def\input#path{{../one-directory/}{../another-directory/}}
\makeatother
\documentclass{myclass}
\usepackage{mypackage}
This way, though, may be not recommended for portability. As other answers mention, the "correct" way is to set the TEXINPUTS variable in your system environment before you call latex; in Windows it is (you can place it in a batch file):
set TEXINPUTS=../one-directory/;../another-directory/;%TEXINPUTS%
pdflatex myfile.tex
Simply put line below before the call to pdflatex (or latex) in your makefile or build script:
export TEXINPUTS=".:./sty:"
Then reference your package as:
\usepackage{prettythesis}

Odd Bibtex behaviour in a Latex document

I added a line "\cite{test}" as a test to my working Latex document. When I compiled the bibtex "!bibtex name_of_my_file, I got the expected error:
Warning--I didn't find a database entry for "test"
Then, I removed the line and compiled the bibtex again, hoping to have a working Latex file again. However, the same error occurs, even with a fresh shell. I cannot understand the behaviour. What is the logic? How can I get my Latex document working again?
[Updated Info]
The problem dissapeared as unexpectedly as it emerged. I have no idea why but it works now. Do you know the reason for the odd behaviour?
I think you are tripping over the multi-pass nature of LaTex plus Bibtex. If you look at Step 3 in this discussion, you'll see the following:
The first run (through latex)
generates an auxiliary file,
paper.aux, containing information
about citations (and other types of
references), the bibliography style
used, and the name of the bibtex
database. The second run (through
bibtex) uses the information in the
auxiliary file, along with the data
contained in the bibtex database, to
create a file paper.bbl. This file
contains a thebibliography environment
with \bibitem entries formatted
according to the bibliography style
specified.
So, what I think is happening is that your name_of_my_file.aux file still contains your placeholder \cite{test}. If you remove the auxiliary file, you should be able to start over with:
latex name_of_my_file
bibtex name_of_my_file
latex name_of_my_file
latex name_of_my_file
[Update based on additional info]: The problem was that you had a .aux file with your \cite{} still embedded. The second time that you ran latex, you overrode the old file with the new. That's why the complete set of steps includes an initial latex call, a bibtex call and two follow-up latex calls. Think of it as a multi-pass compiler and it might be more intuitive.
You could have a look at latexmk, which will take care of the fix point compilation for you.
Anyway, you should be able to build the document (pdflatex blah.tex), even if you're missing a bibliography item. The corresponding references will just appear as question marks in the PDF.
Rerun latex to regenerate the aux file.
Have a look at this discussion for pointers to a bit more information. Basically, you may have taken your citation out of the .tex file, but it still exists in one of the derived files (aux, bbl, whatever...)
Check if your bib file has the extension .bib and not .tex.
If it is .tex, just change it to .bib and that should do it.
Once I changed it accidentally to tex, by adding some references, and saving it with the "save as" option, without specifying the bib extension. That's how it can happen all of a sudden.
delete all your .aux and temporal files, re run with latex and then bibtex and then latex twice.

Resources