1

I am using this command to compile latex file in MacOS:

/Library/TeX/texbin/latexmk -pdfxe -pvc -xelatex -interaction=nonstopmode -output-directory="/Users/dolphin/output"

but the output content is:

$ /Library/TeX/texbin/latexmk -pdfxe -pvc -xelatex -interaction=nonstopmode -output-directory="/Users/dolphin/output"
Latexmk: This is Latexmk, John Collins, 26 Dec. 2019, version: 4.67.
======= Need to update make_preview_continuous for target files
Viewing pdf
Latexmk: applying rule 'makeindex /Users/dolphin/output/dolphin-book-2020.idx'...
Rule 'makeindex /Users/dolphin/output/dolphin-book-2020.idx': The following rules & subrules became out-of-date:
      'makeindex /Users/dolphin/output/dolphin-book-2020.idx'
------------
Run number 1 of rule 'makeindex /Users/dolphin/output/dolphin-book-2020.idx'
------------
------------
Running 'makeindex  -o "/Users/dolphin/output/dolphin-book-2020.ind" "/Users/dolphin/output/dolphin-book-2020.idx"'
------------

makeindex: Not writing to /Users/dolphin/output/dolphin-book-2020.ind (openout_any = p).
Can't create output index file /Users/dolphin/output/dolphin-book-2020.ind.
Usage: makeindex [-ilqrcgLT] [-s sty] [-o ind] [-t log] [-p num] [idx0 idx1 ...]
Latexmk: Errors, so I did not complete making targets
Latexmk: Failure to make the files correctly
    ==> You will need to change a source file before I do another run <==
Collected error summary (may duplicate other messages):
  makeindex /Users/dolphin/output/dolphin-book-2020.idx: Command for 'makeindex /Users/dolphin/output/dolphin-book-2020.idx' gave return code 1
      Refer to '/Users/dolphin/output/dolphin-book-2020.ilg' for details

=== Watching for updated files. Use ctrl/C to stop ...

what should I do to make it work?

1
  • 1
    as the error says: makeindex can't write its output to an absolute folder because of the security setting openout_any = p. Either change the security setting, or write to a subfolder of your main folder or don't use the output-directory option. Dec 2, 2020 at 7:24

1 Answer 1

2

This is a known problem, which I plan to correct in the next release of latexmk.

Meanwhile, you can put the following in a latexmkrc file:

$makeindex = 'internal run_makeindex %S %D %O';

sub run_makeindex {
  my $return = 999;
  my $source = shift;
  my $dest = shift;
  my @opts = @_;
  my ( $source_base, $source_path ) = fileparse( $source );
  my ( $dest_base, $dest_path ) = fileparse( $dest );
  # Paths for source and dest should have been made the same.
  # That's the way latexmk works.

  pushd( $source_path );
  if (!$silent) {
      print "$My_name: Changing directory to '$path'\n",
            "    before running makeindex.\n";
  }
  my @cmd_line = ('makeindex', @options, '-o', $dest_base, $source_base );
  print "$My_name: Running external command '@cmd_line'\n";
  $return = system( @cmd_line );
  popd();
  if (!$silent) {
    print "$My_name: changed directory back to '", cwd(), "'\n";
  }

  return $return;
}

This simply changes directory to the output directory before running makeindex, and then invokes makeindex without any path components in the files. This in fact is what latexmk already does/can do when running bibtex.

2
  • Thanks! How does one use this with texindy instead of makeindex? I want to use it with imakeidx, and pass special options to each of my indices (e.g. \makeindex[title={My index!}, name=myidx, options=-M mystyle.xdy]). Oct 8, 2021 at 19:36
  • BTW, with TeX Live 2021.61403-1 I get this error message: fileparse(): need a valid pathname at (eval 9) line 30. Line 30 is this line in my latexmkrc: my ( $source_base, $source_path ) = fileparse( $source );. Dec 28, 2021 at 15:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .