How can I keep a clean document folder with custom .cls, .sty, .bst files in a separate subfolder?












15















I am using a Makefile for generating a document from its tex source. The whole project consisting of own input files (.tex, .bib, .eps, ...) and non-pre-installed static input files (.cls, .sty, .bst) is kept under version control (git) for colloborative writing. I try to avoid messing up the main folder and use subdirectories for output and different kinds of input files.
All files which are not available within TeX Live should be in the repository to allow everyone a simple git clone and make to create the document. My question is: is there any convenient way which allows me to place all .cls, .sty, .bst into a ./texmf folder with in the document tree:



document-folder
├── .git/...
├── graphics/fig1-<...>.eps
├── graphics/fig2-<...>.eps
├── graphics/...
├── output/docname.pdf
├── output/docname.aux
├── output/...
├── texmf/docclass.cls
├── texmf/custom-package.sty
├── texmf/...
├── docname.tex
├── docname.bib
└── Makefile


The Makefile looks like this



LATEX    := pdflatex
ODIR := ./output
LATEXOPTS:= --output-dir=$(ODIR)

$(TEXFILE).pdf: $(TEXFILE).tex $(TEXFILE).bib
$(LATEX) $(LATEXOPTS) $(TEXFILE).tex


Following solution works but as colloborators have to adjust environment variables every time or their .bashrc for this project, I am not really happy about it:



$ export TEXINPUTS=".:./texmf:~/texmf:$TEXINPUTS"
$ make


Changing environment variables within a Makefile is not possible as far as I know.










share|improve this question

























  • Note that in your question as well as all the answers, a colon (:) is used as path separator. In windows, this does not work, as a semi-colon (;) is used instead. Since linux supports semi-colons as well, it seems like a good practice to me to use them everywhere for better portability.

    – ingomueller.net
    Jul 29 '16 at 9:58
















15















I am using a Makefile for generating a document from its tex source. The whole project consisting of own input files (.tex, .bib, .eps, ...) and non-pre-installed static input files (.cls, .sty, .bst) is kept under version control (git) for colloborative writing. I try to avoid messing up the main folder and use subdirectories for output and different kinds of input files.
All files which are not available within TeX Live should be in the repository to allow everyone a simple git clone and make to create the document. My question is: is there any convenient way which allows me to place all .cls, .sty, .bst into a ./texmf folder with in the document tree:



document-folder
├── .git/...
├── graphics/fig1-<...>.eps
├── graphics/fig2-<...>.eps
├── graphics/...
├── output/docname.pdf
├── output/docname.aux
├── output/...
├── texmf/docclass.cls
├── texmf/custom-package.sty
├── texmf/...
├── docname.tex
├── docname.bib
└── Makefile


The Makefile looks like this



LATEX    := pdflatex
ODIR := ./output
LATEXOPTS:= --output-dir=$(ODIR)

$(TEXFILE).pdf: $(TEXFILE).tex $(TEXFILE).bib
$(LATEX) $(LATEXOPTS) $(TEXFILE).tex


Following solution works but as colloborators have to adjust environment variables every time or their .bashrc for this project, I am not really happy about it:



$ export TEXINPUTS=".:./texmf:~/texmf:$TEXINPUTS"
$ make


Changing environment variables within a Makefile is not possible as far as I know.










share|improve this question

























  • Note that in your question as well as all the answers, a colon (:) is used as path separator. In windows, this does not work, as a semi-colon (;) is used instead. Since linux supports semi-colons as well, it seems like a good practice to me to use them everywhere for better portability.

    – ingomueller.net
    Jul 29 '16 at 9:58














15












15








15


4






I am using a Makefile for generating a document from its tex source. The whole project consisting of own input files (.tex, .bib, .eps, ...) and non-pre-installed static input files (.cls, .sty, .bst) is kept under version control (git) for colloborative writing. I try to avoid messing up the main folder and use subdirectories for output and different kinds of input files.
All files which are not available within TeX Live should be in the repository to allow everyone a simple git clone and make to create the document. My question is: is there any convenient way which allows me to place all .cls, .sty, .bst into a ./texmf folder with in the document tree:



document-folder
├── .git/...
├── graphics/fig1-<...>.eps
├── graphics/fig2-<...>.eps
├── graphics/...
├── output/docname.pdf
├── output/docname.aux
├── output/...
├── texmf/docclass.cls
├── texmf/custom-package.sty
├── texmf/...
├── docname.tex
├── docname.bib
└── Makefile


The Makefile looks like this



LATEX    := pdflatex
ODIR := ./output
LATEXOPTS:= --output-dir=$(ODIR)

$(TEXFILE).pdf: $(TEXFILE).tex $(TEXFILE).bib
$(LATEX) $(LATEXOPTS) $(TEXFILE).tex


Following solution works but as colloborators have to adjust environment variables every time or their .bashrc for this project, I am not really happy about it:



$ export TEXINPUTS=".:./texmf:~/texmf:$TEXINPUTS"
$ make


Changing environment variables within a Makefile is not possible as far as I know.










share|improve this question
















I am using a Makefile for generating a document from its tex source. The whole project consisting of own input files (.tex, .bib, .eps, ...) and non-pre-installed static input files (.cls, .sty, .bst) is kept under version control (git) for colloborative writing. I try to avoid messing up the main folder and use subdirectories for output and different kinds of input files.
All files which are not available within TeX Live should be in the repository to allow everyone a simple git clone and make to create the document. My question is: is there any convenient way which allows me to place all .cls, .sty, .bst into a ./texmf folder with in the document tree:



document-folder
├── .git/...
├── graphics/fig1-<...>.eps
├── graphics/fig2-<...>.eps
├── graphics/...
├── output/docname.pdf
├── output/docname.aux
├── output/...
├── texmf/docclass.cls
├── texmf/custom-package.sty
├── texmf/...
├── docname.tex
├── docname.bib
└── Makefile


The Makefile looks like this



LATEX    := pdflatex
ODIR := ./output
LATEXOPTS:= --output-dir=$(ODIR)

$(TEXFILE).pdf: $(TEXFILE).tex $(TEXFILE).bib
$(LATEX) $(LATEXOPTS) $(TEXFILE).tex


Following solution works but as colloborators have to adjust environment variables every time or their .bashrc for this project, I am not really happy about it:



$ export TEXINPUTS=".:./texmf:~/texmf:$TEXINPUTS"
$ make


Changing environment variables within a Makefile is not possible as far as I know.







texmf build-system makefile environment-variables






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 23 '18 at 16:17







Hotschke

















asked Apr 4 '12 at 10:40









HotschkeHotschke

2,19321841




2,19321841













  • Note that in your question as well as all the answers, a colon (:) is used as path separator. In windows, this does not work, as a semi-colon (;) is used instead. Since linux supports semi-colons as well, it seems like a good practice to me to use them everywhere for better portability.

    – ingomueller.net
    Jul 29 '16 at 9:58



















  • Note that in your question as well as all the answers, a colon (:) is used as path separator. In windows, this does not work, as a semi-colon (;) is used instead. Since linux supports semi-colons as well, it seems like a good practice to me to use them everywhere for better portability.

    – ingomueller.net
    Jul 29 '16 at 9:58

















Note that in your question as well as all the answers, a colon (:) is used as path separator. In windows, this does not work, as a semi-colon (;) is used instead. Since linux supports semi-colons as well, it seems like a good practice to me to use them everywhere for better portability.

– ingomueller.net
Jul 29 '16 at 9:58





Note that in your question as well as all the answers, a colon (:) is used as path separator. In windows, this does not work, as a semi-colon (;) is used instead. Since linux supports semi-colons as well, it seems like a good practice to me to use them everywhere for better portability.

– ingomueller.net
Jul 29 '16 at 9:58










2 Answers
2






active

oldest

votes


















10














You can in fact that environment variables inside a Makefile (tested with GNU make only). You need to do the following:



export VAR=value without quotes


If you reference the previous value of the same variable you need to use the := assignment instead which expands the value immediately. The normal = is expanding the value at every use and will lead to an recursive assignment, which make detects and reports as an error.
There are no quotes required around the value and using them might cause trouble.
Also variables must be written as ${VAR} on the right-hand side, not $VAR.



So you can add the following line to your Makefile, at best at the beginning:



export TEXINPUTS:=.:./texmf:~/texmf:${TEXINPUTS}





share|improve this answer































    15














    I use latexmk for some document building, and I've wanted something like this for a long time. Especially when I have document and class under version control.



    I discovered that you can configure latexmk with a local latexmkrc file in the document's directory. latexmkrc files are just perl code.



    So in this workflow, if the class files are in ./texmf you can add the following line to a local latexmkrc:



    $ENV{'TEXINPUTS'}='./texmf//:' . $ENV{'TEXINPUTS'};


    This works on my Mac, and I assume on any unix machine that uses environment variables this way. For windows, and indeed for any platform, latexmk's author John Collins has a solution at his answer to a similar question.






    share|improve this answer


























    • Thanks. This is good to know, too. However, at the moment I still use existing Makefiles and my colleagues are not aware of latexmk. I will give latexmk a try at the next occasion. The customization feature via a latexmkrc file sounds like a neat way to deal with user-dependent preferences.

      – Hotschke
      Apr 5 '12 at 17:11











    • Could you clarify that latexmkrc doesn't need a preceding dot in its name?

      – einpoklum
      Jun 20 '16 at 21:04











    • @einpoklum According to the manual, it will work with or without the dot.

      – Matthew Leingang
      Jun 21 '16 at 0:28











    • @MatthewLeingang this does not seem to work on Windows.

      – Krishna
      Feb 13 at 19:01











    • @Krishna Unfortunately I have no experience with latexmk and Windows. There is some documentation by third party users on how to make it work though.

      – Matthew Leingang
      Feb 13 at 20:14











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f50697%2fhow-can-i-keep-a-clean-document-folder-with-custom-cls-sty-bst-files-in-a-s%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    10














    You can in fact that environment variables inside a Makefile (tested with GNU make only). You need to do the following:



    export VAR=value without quotes


    If you reference the previous value of the same variable you need to use the := assignment instead which expands the value immediately. The normal = is expanding the value at every use and will lead to an recursive assignment, which make detects and reports as an error.
    There are no quotes required around the value and using them might cause trouble.
    Also variables must be written as ${VAR} on the right-hand side, not $VAR.



    So you can add the following line to your Makefile, at best at the beginning:



    export TEXINPUTS:=.:./texmf:~/texmf:${TEXINPUTS}





    share|improve this answer




























      10














      You can in fact that environment variables inside a Makefile (tested with GNU make only). You need to do the following:



      export VAR=value without quotes


      If you reference the previous value of the same variable you need to use the := assignment instead which expands the value immediately. The normal = is expanding the value at every use and will lead to an recursive assignment, which make detects and reports as an error.
      There are no quotes required around the value and using them might cause trouble.
      Also variables must be written as ${VAR} on the right-hand side, not $VAR.



      So you can add the following line to your Makefile, at best at the beginning:



      export TEXINPUTS:=.:./texmf:~/texmf:${TEXINPUTS}





      share|improve this answer


























        10












        10








        10







        You can in fact that environment variables inside a Makefile (tested with GNU make only). You need to do the following:



        export VAR=value without quotes


        If you reference the previous value of the same variable you need to use the := assignment instead which expands the value immediately. The normal = is expanding the value at every use and will lead to an recursive assignment, which make detects and reports as an error.
        There are no quotes required around the value and using them might cause trouble.
        Also variables must be written as ${VAR} on the right-hand side, not $VAR.



        So you can add the following line to your Makefile, at best at the beginning:



        export TEXINPUTS:=.:./texmf:~/texmf:${TEXINPUTS}





        share|improve this answer













        You can in fact that environment variables inside a Makefile (tested with GNU make only). You need to do the following:



        export VAR=value without quotes


        If you reference the previous value of the same variable you need to use the := assignment instead which expands the value immediately. The normal = is expanding the value at every use and will lead to an recursive assignment, which make detects and reports as an error.
        There are no quotes required around the value and using them might cause trouble.
        Also variables must be written as ${VAR} on the right-hand side, not $VAR.



        So you can add the following line to your Makefile, at best at the beginning:



        export TEXINPUTS:=.:./texmf:~/texmf:${TEXINPUTS}






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 4 '12 at 14:07









        Martin ScharrerMartin Scharrer

        202k46643821




        202k46643821























            15














            I use latexmk for some document building, and I've wanted something like this for a long time. Especially when I have document and class under version control.



            I discovered that you can configure latexmk with a local latexmkrc file in the document's directory. latexmkrc files are just perl code.



            So in this workflow, if the class files are in ./texmf you can add the following line to a local latexmkrc:



            $ENV{'TEXINPUTS'}='./texmf//:' . $ENV{'TEXINPUTS'};


            This works on my Mac, and I assume on any unix machine that uses environment variables this way. For windows, and indeed for any platform, latexmk's author John Collins has a solution at his answer to a similar question.






            share|improve this answer


























            • Thanks. This is good to know, too. However, at the moment I still use existing Makefiles and my colleagues are not aware of latexmk. I will give latexmk a try at the next occasion. The customization feature via a latexmkrc file sounds like a neat way to deal with user-dependent preferences.

              – Hotschke
              Apr 5 '12 at 17:11











            • Could you clarify that latexmkrc doesn't need a preceding dot in its name?

              – einpoklum
              Jun 20 '16 at 21:04











            • @einpoklum According to the manual, it will work with or without the dot.

              – Matthew Leingang
              Jun 21 '16 at 0:28











            • @MatthewLeingang this does not seem to work on Windows.

              – Krishna
              Feb 13 at 19:01











            • @Krishna Unfortunately I have no experience with latexmk and Windows. There is some documentation by third party users on how to make it work though.

              – Matthew Leingang
              Feb 13 at 20:14
















            15














            I use latexmk for some document building, and I've wanted something like this for a long time. Especially when I have document and class under version control.



            I discovered that you can configure latexmk with a local latexmkrc file in the document's directory. latexmkrc files are just perl code.



            So in this workflow, if the class files are in ./texmf you can add the following line to a local latexmkrc:



            $ENV{'TEXINPUTS'}='./texmf//:' . $ENV{'TEXINPUTS'};


            This works on my Mac, and I assume on any unix machine that uses environment variables this way. For windows, and indeed for any platform, latexmk's author John Collins has a solution at his answer to a similar question.






            share|improve this answer


























            • Thanks. This is good to know, too. However, at the moment I still use existing Makefiles and my colleagues are not aware of latexmk. I will give latexmk a try at the next occasion. The customization feature via a latexmkrc file sounds like a neat way to deal with user-dependent preferences.

              – Hotschke
              Apr 5 '12 at 17:11











            • Could you clarify that latexmkrc doesn't need a preceding dot in its name?

              – einpoklum
              Jun 20 '16 at 21:04











            • @einpoklum According to the manual, it will work with or without the dot.

              – Matthew Leingang
              Jun 21 '16 at 0:28











            • @MatthewLeingang this does not seem to work on Windows.

              – Krishna
              Feb 13 at 19:01











            • @Krishna Unfortunately I have no experience with latexmk and Windows. There is some documentation by third party users on how to make it work though.

              – Matthew Leingang
              Feb 13 at 20:14














            15












            15








            15







            I use latexmk for some document building, and I've wanted something like this for a long time. Especially when I have document and class under version control.



            I discovered that you can configure latexmk with a local latexmkrc file in the document's directory. latexmkrc files are just perl code.



            So in this workflow, if the class files are in ./texmf you can add the following line to a local latexmkrc:



            $ENV{'TEXINPUTS'}='./texmf//:' . $ENV{'TEXINPUTS'};


            This works on my Mac, and I assume on any unix machine that uses environment variables this way. For windows, and indeed for any platform, latexmk's author John Collins has a solution at his answer to a similar question.






            share|improve this answer















            I use latexmk for some document building, and I've wanted something like this for a long time. Especially when I have document and class under version control.



            I discovered that you can configure latexmk with a local latexmkrc file in the document's directory. latexmkrc files are just perl code.



            So in this workflow, if the class files are in ./texmf you can add the following line to a local latexmkrc:



            $ENV{'TEXINPUTS'}='./texmf//:' . $ENV{'TEXINPUTS'};


            This works on my Mac, and I assume on any unix machine that uses environment variables this way. For windows, and indeed for any platform, latexmk's author John Collins has a solution at his answer to a similar question.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 14 at 18:19

























            answered Apr 5 '12 at 12:15









            Matthew LeingangMatthew Leingang

            35.1k10106178




            35.1k10106178













            • Thanks. This is good to know, too. However, at the moment I still use existing Makefiles and my colleagues are not aware of latexmk. I will give latexmk a try at the next occasion. The customization feature via a latexmkrc file sounds like a neat way to deal with user-dependent preferences.

              – Hotschke
              Apr 5 '12 at 17:11











            • Could you clarify that latexmkrc doesn't need a preceding dot in its name?

              – einpoklum
              Jun 20 '16 at 21:04











            • @einpoklum According to the manual, it will work with or without the dot.

              – Matthew Leingang
              Jun 21 '16 at 0:28











            • @MatthewLeingang this does not seem to work on Windows.

              – Krishna
              Feb 13 at 19:01











            • @Krishna Unfortunately I have no experience with latexmk and Windows. There is some documentation by third party users on how to make it work though.

              – Matthew Leingang
              Feb 13 at 20:14



















            • Thanks. This is good to know, too. However, at the moment I still use existing Makefiles and my colleagues are not aware of latexmk. I will give latexmk a try at the next occasion. The customization feature via a latexmkrc file sounds like a neat way to deal with user-dependent preferences.

              – Hotschke
              Apr 5 '12 at 17:11











            • Could you clarify that latexmkrc doesn't need a preceding dot in its name?

              – einpoklum
              Jun 20 '16 at 21:04











            • @einpoklum According to the manual, it will work with or without the dot.

              – Matthew Leingang
              Jun 21 '16 at 0:28











            • @MatthewLeingang this does not seem to work on Windows.

              – Krishna
              Feb 13 at 19:01











            • @Krishna Unfortunately I have no experience with latexmk and Windows. There is some documentation by third party users on how to make it work though.

              – Matthew Leingang
              Feb 13 at 20:14

















            Thanks. This is good to know, too. However, at the moment I still use existing Makefiles and my colleagues are not aware of latexmk. I will give latexmk a try at the next occasion. The customization feature via a latexmkrc file sounds like a neat way to deal with user-dependent preferences.

            – Hotschke
            Apr 5 '12 at 17:11





            Thanks. This is good to know, too. However, at the moment I still use existing Makefiles and my colleagues are not aware of latexmk. I will give latexmk a try at the next occasion. The customization feature via a latexmkrc file sounds like a neat way to deal with user-dependent preferences.

            – Hotschke
            Apr 5 '12 at 17:11













            Could you clarify that latexmkrc doesn't need a preceding dot in its name?

            – einpoklum
            Jun 20 '16 at 21:04





            Could you clarify that latexmkrc doesn't need a preceding dot in its name?

            – einpoklum
            Jun 20 '16 at 21:04













            @einpoklum According to the manual, it will work with or without the dot.

            – Matthew Leingang
            Jun 21 '16 at 0:28





            @einpoklum According to the manual, it will work with or without the dot.

            – Matthew Leingang
            Jun 21 '16 at 0:28













            @MatthewLeingang this does not seem to work on Windows.

            – Krishna
            Feb 13 at 19:01





            @MatthewLeingang this does not seem to work on Windows.

            – Krishna
            Feb 13 at 19:01













            @Krishna Unfortunately I have no experience with latexmk and Windows. There is some documentation by third party users on how to make it work though.

            – Matthew Leingang
            Feb 13 at 20:14





            @Krishna Unfortunately I have no experience with latexmk and Windows. There is some documentation by third party users on how to make it work though.

            – Matthew Leingang
            Feb 13 at 20:14


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f50697%2fhow-can-i-keep-a-clean-document-folder-with-custom-cls-sty-bst-files-in-a-s%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to change which sound is reproduced for terminal bell?

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

            Can I use Tabulator js library in my java Spring + Thymeleaf project?