Sunday, August 6, 2023

library, bib, and pdflatex

Oh bibliographies. Yuck

do not use underscores in file names

Underscores are tidier than camel-case and I have relied on them over and over throughout the years. They met their match with LaTeX. I no longer use them for any filename in case I need to cite it in a LaTeX document.

old
20230705_smogreceipt
new
20230705smogreceipt

successful process

Using Geany or whatever...

  1. check the bib file for underscores and cleanness
  2. have the BIB file reachable by the filepath in \addlibresource
  3. run the TEX a first time, using the build menu "Latex -> PDF" option (pdflatex)
  4. run the TEX a second time, using the build menu "Bibtex" option (creates the BLG)
  5. run the TEX a third time using the "Latex -> PDF" option (pdflatex)

bibliography failures

Bibtex and/or pdflatex fail in different ways with underscores, but by far the worst problem is the cascade failure coming from bibtex. Pdflatex makes a call to bibtex and bibtex returns a BLG file. Any underscores in the "notes" field --eg filenames -- will be included, and pdflatext will reject the entire bibliography for one underscore. This is because pdflatex requires underscores to be preceeded by either a backslash or a $ (math mode). Sometimes an underscore from bibtex causes the entire PDF not to be written by pdflatex.

Accordingly, the data retention plan described in the prior post should not rely on filenaming using underscores. The URL field is the only exception. Bibtex or pdflatex will fail downstream

BIB specific fail

There's also a way bibtex can fail independently of pdflatex. In that case, it fails to send a BLG to pdflatex at all. This comes from the "crossreference" field often used by ppl to store notes about file locations of their saved journals and so on. When the Bibtex subroutine runs, it attempts to verify this location, even going through the Web or whatever. It's obviously not going to locate the thumbdrive folder that you left yourself a note about. And thus from one "crossref" failure, it will fail to produce a BLG file. Thus no bibliography.

BIB file include

Generally, author, title, date, url (can use underscores), DOI, abstract, pages, ISBN or ISSN. Leave out notes and crossref.

Populate your bib files with all the information to span whatever style you've decided upon (MLA, APA, etc), but never include or enter anything into the "crossref" field, which causes large problems when finally compiling via bibtex

This way, if a publisher does eventually look at the work, a person can reformat their TEX file to use that style of citation. Some of this is manual decision making.

Note that large organizations like grammarly.com probably are influencers and have inertia, so they might be a good resource to consider, eg this MLA v APA page. Works cited (MLA) and Reference (APA) is a key distinction. Frankly, I believe the format should be listed along with the title to keep people from being confused.

LaTeX integration of BIB

Once all of these are connected, how do we work them into our LaTeX documents. What codes do we need? How can we have consistent citations? For one thing, the document doesn't need to access the articles, just the BIB file. Yes, we need to look those, and typically save the research articles somewhere, but the document doesn't need any of that to compile, it just needs BIB file access.

In Arch, probably need the 37Mbbiblatex package to get anything to compile.

# pacman -S texlive-bibtexextra

More is described here, but the basics...

  • package -- \usepackage[style=mla,backend=bibtex]{biblatex}
  • BIB file -- underneath package \addbibresource {BIB filename}. Append the path to the filename if it's in a different directory.
  • Inline citations -- use \cite{[BIB item key]}. This can be alpha-numeric. No underscores of course.
  • Multiple BIBS -- described here.

bibliography checklist

NO UNDERSCORED ANYTHING IN ANY BIB FILE EXCEPT THE "URL" FIELD WITHIN ITS CURLY BRACES.

DO NOT SAVE ANY DOCUMENTS WITH UNDERSCORES, NOR NAME TEX OR BIB FILES WITH UNDERSCORES. Bibliographies will not print.

Order: pdflatex, bibtex, pdflatex.

Bibtex itself fails if any file in "crossref" field cannot be located within it.

No comments: