1

I am writing a mac os double-click bash command file X.command to execute a sequence of pdflatex-ing of various LaTeX files. In the directory containing the files there is an included style file BICA.sty that the LaTeX Files use.

>ls
BICA.sty    X.command   cover.tex

A MWE for X.command is

#!/bin/bash
DIRNAME=`dirname "$0"`
pdflatex "$DIRNAME"/cover.tex
read -p

When I open a finder window and double-click X.command I get this error:

! LaTeX Error: File `BICA.sty' not found.

Note:

  1. there will be several files in the directory to pdflatex.
  2. It all works fine if I run it from a terminal window command line.
  3. I am writing this command for less sophisticated users to use.
  • don't do that, do cd $DIRNAME; pdflatex cover so it runs from the files directory – David Carlisle Jan 29 '17 at 17:24
  • When I do that I get: ! I can't find file `cover'. – Don Kreher Jan 29 '17 at 17:57
  • Does DIRNAME have spaces in it? Then use cd "$DIRNAME". Is there some reason the "less sophisticated user" shouldn't just use a front end to the distribution like TeXShop? TeXShop has some engines that use latexmk which take care of all processing (with some help if sosmething sophisticaed is going to be used). Finally, what distribution did you install? – Herb Schulz Jan 29 '17 at 18:07
  • as Herb says you'll need quotes if there spaces in the directory name. – David Carlisle Jan 29 '17 at 18:16
  • Yes DIRNAME has a space in it and the double quotes worked. I never use these front end engines, so I don't know how you instruct one to first pdflatex these 20 files (twice) before doing this last one (twice) for example. So I was building a simple bash script that he could run. I think I have installed Texlive but I never use the front end. – Don Kreher Jan 29 '17 at 18:17
1

Input files are always relative to the working directory not the directory with the file, so arrange that the working directory is the directory with the file.

use:

cd "$DIRNAME"; pdflatex cover 

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.