2

I have a project directory and within the project directory a package in a local texmf-tree. As the project resides in a repository and is compiled on different computers, I would like to have a compile command that first sets the TEXMFHOME variable and then executes pdflatex. Last, I use texstudio v2.10.8. How could I get this working?

In my real scenario I want the packages also to be found in multiple tex-files located in subfolders. Hence, the use of TEXMFHOME.

MWE

I have a file main.tex

\documentclass{article}
\usepackage{foo}
\begin{document}
    \foo
\end{document}

and foo.sty in texmf/tex/latex/

\newcommand{\foo}{c}

Also, a file Makefile with content

MAIN=main

compile:
        export TEXMFHOME=./texmf/
        pdflatex $(MAIN).tex

.PHONY: clean force once all

From command line it works as expected. If I execute /usr/bin/make from texstudio it does not find foo.sty.

  • 2
    Might be more of a make or shell question (perhaps TeXstudio uses /bin/sh which may or may not be the same as /bin/bash). Have you tried TEXMFHOME=./texmf/ pdflatex $(MAIN).tex all on one line? Alternatively, three lines of TEXMFHOME=./texmf/, export TEXMFHOME, pdflatex $(MAIN).tex? – Mike Renfro Aug 13 '17 at 13:01
  • TEXMFHOME=./texmf/ pdflatex $(MAIN).tex seems to work. Do you have any ideas why that would work? I mean, usually I would use ; to sequentialize commands. But then it does not work when calling from texstudio. – Heinrich Ody Aug 13 '17 at 14:45
  • The one line version explicitly sets an environment variable for the following command, and that variable is deleted once that command finishes. Works in all Bourne-type shells, at a minimum (haven't used a non-Bourne shell in 20-25 years or so). If my 3-line option (set variable, export variable, run pdflatex) works as intended, and especially if you also see that /bin/sh is a link to dash instead of bash, then the problem is that export NAME=value is a bash-ism, and can't be expected to work in other Bourne-type shells. The three-line version is universal. – Mike Renfro Aug 13 '17 at 14:51
  • 3
    From within make it uses /bin/sh and from command line /bin/bash. Also, the three line version did not work from within texstudio... – Heinrich Ody Aug 13 '17 at 14:52
  • Then you can't use a one-line export NAME=value inside the Makefile. You should be able to chain as many of those variables together as needed, though: NAME1=value1 NAME2=value2 pdflatex $(MAIN).tex. – Mike Renfro Aug 13 '17 at 14:55
  • It works with your suggestions, thanks! However, I do not understand why some things work when executed from command line (like any version using export), but not from within texstudio. – Heinrich Ody Aug 14 '17 at 09:35
  • 1
    I'm assuming the Makefile works consistently, regardless if you run it from the command line or from TeXstudio. The GNU make manual indicates that it'll use /bin/sh as the default shell. If /bin/sh is a symlink to bash, it'll behave like this. If it's a symlink to dash as I suspect, then bash-specific commands like export N=v won't work, any more than \newcommand would work with regular TeX. – Mike Renfro Aug 15 '17 at 00:51
  • 1
    @MikeRenfro, Is there a way to define variable in TeXStudio as part of a command? For instance, I tried export LC_ALL="en_US"; lualatex -synctex=1 -interaction=nonstopmode %.tex but it won't work. I need to set LC_ALL="en_US" in TeXStudio environment before running LuaLaTeX. – Royi May 27 '18 at 04:16
  • @Royi if you’re not using make to build, these answers probably aren’t relevant. None of this is influenced by the editor. I suggest posting a separate question for better chances of getting an answer. – Mike Renfro May 27 '18 at 08:32

0 Answers0