2

While investigating some things about TeX, I stumbled across TEXINPUTS, which one can use to tell (La/pdf/..?)TeX where to find it's files. I decided to look into it a bit closer and learned about kpathsea, which seems to be where TEXINPUTS is used to guide file search. kpathsea also defines some other variables, like TEXMFHOME, TEXMFDIST and most importantly TEXMF, which is used in the definition of TEXINPUTS in the texmf.cnf file: TEXINPUTS = $TEXMFDOTDIR;$TEXMF/tex/{$progname,generic,latex,}//.

Therefore, one can read the order in which the texmf trees are searched (by default) from the definition of TEXMF.

What I am curious about is whether this works not only with TeX Live, but also MikTeX and other distributions. The texmf.cnf file is located in a subfolder of texlive. According to Christian Schenk's comment on this post, MikTeX does not use kpathsea but rather an emulation of it. MikTeX also has an env-var called TEXINPUTS, but I couldn't find anything about the other TEXMF variables.

If MikTeX does not use the TEXMF variable, how is the precedence of the different trees / roots handled?

3
  • you can change the order in the miktex console. miktex then stores that in one of its configuration files. Commented Sep 22, 2023 at 14:17
  • @UlrikeFischer I didn't know that, thank you. AFAIK, with TeX Live TEXINPUTS dictates the order in which the TEXMF trees are searched, whereas with Miktex you said its stored in a config file. Miktex also recognizes TEXINPUTS (See the link on TEXINPUTS in my post). Does it have a different meaning with Miktex than with texlive/kpathsea? Commented Sep 25, 2023 at 10:30
  • Texinputs has nothing to do with the tree order Commented Sep 25, 2023 at 12:19

1 Answer 1

-1

I don't know about the use of TEXMF, but I think I can infer a conclusion for you. I do use TEXINPUTS with MiKTeX (Windows). Its behavior is not consistent with my texliveFull installation (Nix Home Manager on Linux)

How to use TEXINPUTS with MiKTeX? For MiKTeX I must declare:

#!/usr/bin/env bash
(export TEXINPUTS="$DATA_DIR" && pdflatex $TARGET_FILE)

For Texlive I must declare:

#!/usr/bin/env bash
(export TEXINPUTS=".;$DATA_DIR;" && pdflatex $TARGET_FILE)

I grep the result of pdflatex --version for "MiKTeX" and if present, use "$DATA_DIR" and otherwise use ".;$DATA_DIR;" for cross-platform compatibility.

This could be done as part of a bash script:

#!/usr/bin/env bash
if pdflatex --version | grep -q 'MiKTeX'; then
  (export TEXINPUTS="$DATA_DIR" && pdflatex "$TARGET_FILE")
else
  (export TEXINPUTS=".;$DATA_DIR;" && pdflatex "$TARGET_FILE")
fi

I do this in a Makefile:

$(OUT_DIR)/%.pdf : $(BUILD_DIR)/%.tex
    @mkdir -p "$(OUT_DIR)"
    @echo "Compiling $(BOLD)$@$(SGR0)..."
    @if pdflatex --version | grep -q 'MiKTeX'; then \
        (export TEXINPUTS="$(DATA_DIR)" && pdflatex "$TARGET_FILE") \
    else \
        (export TEXINPUTS=".;$(DATA_DIR);" && pdflatex "$TARGET_FILE") \
    fi

Because the behavior of TEXINPUTS is different from other pdflatex distributions, and TEXMF is not listed in the documentation, I think it is safe to assume that TEXMF is not supported by MiKTeX.

3
  • downvote with no explanation :( me sad Commented Aug 1 at 16:38
  • I'm afraid drive-by down-voting is too popular a pastime. I don't think the documentation you linked proves what you think. I don't use miktex, but I assume 'environmental variables' has the usual meaning. if so, the lack of e.g. TEXMF from the list means nothing. texlive doesn't use it as an environmental variable. in fact, texlive doesn't typically depend on any environmental variables at all. (indeed, if it finds anything suspicious in the environment when installing, the installer warns you with a list of variables which could cause trouble.) it uses config files and commandline. args
    – cfr
    Commented Aug 2 at 1:51
  • if you set things in the environment, this will affect texlive binaries, but that's why you generally shouldn't set such things in your environment. I seriously doubt this has anything to do with the down-vote. that seems just part of the random site noise.
    – cfr
    Commented Aug 2 at 1:53

You must log in to answer this question.

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