1

I have already set a new folder called _build for separating and including the generated aux and bib files of pdflatex and bibtex in Texstudio (with Miktex) as follows: Texstudio --> Options --> Configure Texstudio --> Commands:

pdflatex.exe -synctex=1 -interaction=nonstopmode --aux-directory=_build %.tex

bibtex.exe _build/% -include-directory=_build

The above configuration works fine and the PDF is output as desired.

However when I tried to do the same with makeindex (using \usepackage{imakeidx} and \makeindex in the preamble, and \printindex in the body document) and then I changed the configuration of makeindex in Texstudio commands as follows: Texstudio --> Options --> Configure Texstudio --> Commands:

makeindex.exe _build/%.idx -include-directory=_build

Although I see the myfile.idx created in the _build folder but the Index is not created in the document and I receive this message:

Input index file myfile.idx not found. Usage: makeindex [-ilqrcgLT] [-s sty] [-o ind] [-t log] [-p num] [idx0 idx1 ...]

Is there a way to include the new folder path _build correctly in the makeindex command?

  • A work around can be copying the created myfile.idx from the _build folder and pasting it in the root folder (next to myfile.tex) and then recompile. The index would then print fine. But that's not what I want. I'd rather, if possible, to follow a similar configuration as I did to pdflatex.exe and bibtex.exe and apply it to makeindex.exe. – hesham Jan 26 at 11:16
  • I am sure many will correctly point out that you should "always" run the miscellany of commands and files in ONE folder with the .tex even if that is a subfolder of main There are so many interacting packages that depend on the relative same location without redirecting unless by means of env variables (e.g. you can store all bib related files together using bibinput variable) AFAIK there is no one specific for makeindex although MiKTeX has one for redirecting build folders. Back to your need {imakeidx} hooks makeindex so could try like \makeindex[options=-o ./_build] so read manuals – user170109 Jan 26 at 14:24
  • this may help nwalsh.com/tex/texhelp/mkidx-2.html OR in TeXstudio change makeindex.exe %.idx to something like makeindex.exe -o ./build/%.idx however I have to let you play with those -i -o options as I'm otherwise tied up – user170109 Jan 26 at 14:51
  • @KJO Thx. Tried all the above suggestion with all possible combinations, nothing seems to do the trick! Still stuck at Input index file myfile.idx not found. message. – hesham Jan 26 at 15:32
  • 1
    Similar to tex.stackexchange.com/questions/420573/… makeindex is the most difficult to reassign (though may not be impossible if you get syntax right for your mix of system and editor see samcarters suggestion for a ltx2any helper BUT it requires yet another dependency of RUBY and you've got enough potential issues without yet another , interfering app, personally would run makeindex in same folder as .tex then script final postprocessing helper macro/user command via shortcuts to flush the files down to subfolder after last pdfTeX run – user170109 Jan 26 at 16:53
2

This is possible and certainly works from the command line (However as described certainly not advised for all cases) Here is a composed image of the folders during runtime

enter image description here

The files on the right are in the subfolder "build", which is created by the first PdfLaTeX run (however if you have a bib or other support file you need to make the folder to put it/them in first) whilst the central file group is in folder book_2. Note the "(busy)" file flashes on/off whilst building & disappears once the run is done.

There were many attempts to resolve issues I encountered with TeXstudio running the following series of console commands. and have come to the conclusion that TeXstudio is OK for the first compile and makeindex plus the biber run BUT output from Texstudio produced wrong result on the final pdfLaTeX and although my template suggested an additional run, only on one occasion did it work and whatever I did even deleting the build folder it would run past the desired result thus destroying the final bibliography structure !!

What did work was running from the command line, so I have to presume TeXstudio adds too much poke, anyway here are the commands I ran

Note -s StyleInd.ist was a requirement of my test files (not normally required)

pdflatex.exe  -synctex=1 -interaction=nonstopmode -output-directory ./build/ main
makeindex.exe ./build/main.idx  -s ./build/StyleInd.ist
biber.exe ./build/main
pdflatex.exe  -synctex=1 -interaction=nonstopmode -output-directory ./build/ main

And inside TeXstudio they are (without my -s ./build/StyleInd.ist)

pdflatex.exe  -synctex=1 -interaction=nonstopmode -output-directory ./build/ %.tex

bibtex.exe ./build/%

makeindex.exe ./build/%.idx  
  • Let me try that before I give you my feedback. – hesham Jan 27 at 14:11
  • Thanks for your time and answer. I used your proposed commands makeindex.exe ./build/%.idx from within Texstudio/options/commands, and still the index file *.idx cannot be found by makeindex. Unfortunately, running from the command line is not an option for me as it seems not handy enough while continuously editing and compiling the main document. – hesham Jan 27 at 21:03
  • 1
    ODD did you add the altered prior line for pdfLaTeX -output-directory ./build/ with a space before %.tex (you can watch with explorer that it creates that subfolder NOT a folder called main.tex which was one issue kept tripping me up :-) BEST copy existing pdflatex to a new profile so default not corrupted, but I don't readilly know how to in TeXstudio so just modified the default command Other editors allow easier linking of new build steps but in your case need one dedicated pdflatex run before makeindex, hence the issues with so many ways editors can be mis-configured. – user170109 Jan 27 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.