rreusser / gulp-latex

A gulp plugin for rendering LaTeX files
6 stars 3 forks source link

Can't find custom cls files #1

Open coaxial opened 9 years ago

coaxial commented 9 years ago

If I have the following tree:

.
├── gulpfile.js
├── lib
│   └── texdocs
│       ├── customclass.cls
│       └── document.tex
└── package.json

And document.tex's document class is customclass.cls

Then the plugin doesn't output any pdf because it can't find customclass.cls.

The same thing happens on the CLI:

$ pwd
/some/path

$ pdflatex lib/texdocs/document.tex
# pdflatex errors because it can't find customclass.cls that document.tex refers to

$ TEXINPUTS='lib/texdocs' document.tex
# pdflatex errors because it's looking for article.cls (which customclass.cls is based on) in lib/texdocs

$ cd lib/texdocs && pdflatex document.tex
# all is well, document.tex compiles and we have document.pdf in ./
rreusser commented 9 years ago

Hmm… that's a good question. This question suggests maybe there are a couple variations of TEXINPUTS that might be helpful in this situation: http://tex.stackexchange.com/questions/93712/definition-of-the-texinputs-variable

(Specifically, do you need TEXINPUTS=./lib/texdocs:/usr/local/share/???/texdocs or wherever your tex installation resides? This is slightly outside of my current knowledge of latex setup)

Otherwise, is it possible to specify the working directory in the gulp file when you select sources? See: https://github.com/gulpjs/gulp/blob/master/docs/recipes/specifying-a-cwd.md

gulp.src('./some/dir/**/*.js', { cwd: 'public' });

If it works, I think that might be the best solution since it's minimally invasive and puts the onus of getting this right on the particular script you're using.

I think it would also be possible to just use cd ${your_dir} && latex (that's es6 string interpolation syntax that I couldn't remember how to wrap with backticks in markdown, but whatever works for you).

That's just a few shots in the dark, so let me know if you still have any trouble!

coaxial commented 9 years ago

I couldn't find any other solution than using gulp-shell or child_process.exec() which both let you set the cwd. It's not ideal and probably doesn't handle errors and other odd conditions as well as your plugin or the underlying module though but I couldn't get anything else to work.