1

The AMSRefs package documentation says the following in Section 2.2 Using an .ltb database file:

[S]uppose you have a file nonsense.ltb with the following contents:

\documentclass{article}

\usepackage{amsrefs}

\begin{document}

\begin{bibdiv}

\begin{biblist}

\bib{Bourbaki70}{book}{
    title={Th\’eorie des ensembles},
    author={Bourbaki, Nicolas},
    date={1970},
    publisher={Hermann},
    address={Paris}
}

\bib{Sokal96}{article}{
    title={Trangressing the boundaries},
    subtitle={Toward a transformative hermeneutics of quantum gravity},
    author={Sokal, Alan},
    journal={Social Text},
    volume={46/47},
    date={1996},
    pages={217--252}
}

\bib{SokalB1998}{book}{
    title={Fashionable Nonsense},
    subtitle={Postmodern Intellectuals’ Abuse of Science},
    author={Sokal, Alan},
    author={Bricmont, Jean},
    publisher={Picador USA},
    address={New York},
    date={1998}
}

\end{biblist}

\end{bibdiv}

\end{document}

Before seeing how this affects our sample document, take note of a couple of aspects of the format of nonsense.ltb:

  1. We have chosen to format nonsense.ltb as a complete LaTeX document. This is so we can produce a formatted listing of our whole database by running nonsense.ltb through LaTeX. However, this is not necessary; when amsrefs treats nonsense.ltb as a database file, it ignores everything except for the \bib commands.

What is meant by "running nonsense.ltb through LaTeX"? Do I open the database file nonsense.ltb in my LaTeX editor (I am using TeXShop) and then run pdftex? But won't this require it to be a .tex file, rather than an .ltb file?

I actually tried creating a file nonsense.ltb with the above content and opening it in TeXShop, but the options to typeset the document as either 'Plain TeX' or 'LaTeX', etc. under the Typeset menu bar item are grayed out, and I'm unable to typeset the .ltb file. These are the options I see when I open in the menu bar in this case:

This is how the menu bar item looks for other (.tex) documents that I am able to typeset using ⌘T.

4
  • 2
    @TheAmplitwist You could always run it via command line. On the other hand, I do not see why you could not rename it as .tex-file. I fathom that the developers only use a different file extension to separate the document file from the bibliography-file, but if your LaTeX editor is too stubborn for that, just rename it into "*.tex". It is a full TeX-file after all, and will compile as long as \usepackage{amsrefs} defines the bibdiv and biblist environments. Jun 28, 2021 at 10:54
  • 1
    The problem I see is that this will generate a separate .pdf-file with just the bibliography. I could imagine that the thinking behind the amsrefs-package is, that you are supposed to call the .ltb-file of the same name from within the .tex-file (although it would then be weird to structure the .ltb-file as a complete .tex-file with its own documentclass{} and begin{document}). The documentation of amsrefs should give you details on how it is supposed to be combined with the .tex-file to generate a bibliography integrated into the main document. Jun 28, 2021 at 10:57
  • @ManuelWeinkauf Thank you for your comments! Unfortunately, I am not (yet) familiar with the command line tools, so I do not know how to run the .ltb file through LaTeX via the command line. I tried your next suggestion and renamed the file as nonsense.ltb.tex, and also as nonsense.tex. In both cases, TeXShop understands to compile it via LaTeX. Moreover, I am able to use \bibselect{nonsense} in my sample document successfully regardless of how the database file is named: nonsense.ltb, nonsense.ltb.tex and nonsense.tex all work fine. (My apologies in case all this is trivial.) Jun 28, 2021 at 11:36
  • 1
    @ManuelWeinkauf Perhaps the idea behind this is indeed as you suggest, namely to run the database file through LaTeX in order to generate a separate .pdf file with all the bibliography entries typeset… Jun 28, 2021 at 11:38

1 Answer 1

2

TeXShop is trying to be (not) very smart and it only allows files with extensions .tex and, as far as I can see, also .ltx to be typeset.

However, you can act on a hidden preference. On a Terminal window, type

defaults write TeXShop OtherTeXExtensions \(ltb\)

and hit return. Thereafter you will be able to typeset also .ltb files.

Screenshot of the TeXShop editor with the file nonsense.ltb opened. The "Typeset" option is seen to be available.

As you see, the “Typeset” button is no longer grayed out. Here's the console output:

Screenshot of the console log after running LaTeX.

The resulting PDF is:

Screenshot of the typeset PDF.

Alas, the hidden preference is not even listed in the documentation coming with the program.

The value of the preference must be a comma separated list in parentheses, so you could do

defaults write TeXShop OtherTeXExtensions \(ltb,abc,def\)

if you need to add other extensions.

3
  • Thank you! I tried changing the defaults as you instructed and it has worked. I have a couple of questions: (1) My curiosity, how did you locate this hidden preference that is not listed even in the documentation? :) (2) Can something "bad" happen if I try to typeset non .tex files (that is, other than the file not compiling at all)? Basically, I'm just wondering about why TeXShop's defaults are set the way they are. Jun 30, 2021 at 17:05
  • 2
    @TheAmplitwist I tried to run defaults read TeXShop and the line with OtherTeXExtensions=() showed up. It was just a look at the other preferences to understand what writing in the preference. You can typeset any file with an extension from the Terminal, just run pdflatex filename.ext. If it is a well formed LaTeX file, you'll get the output. Apparently the author of TeXShop wanted to avoid running TeX on strange files. It is conceivable to craft a malicious file that hides \write instructions, but the usual settings of TeX Live prohibits writing in directories above the working one.
    – egreg
    Jun 30, 2021 at 17:23
  • Thank you very much, this was instructive. :) Jun 30, 2021 at 17:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .