Automating Multi-Pass Processing with latexmk and TeXShop.

The official TeXShop Support Forum.

Automating Multi-Pass Processing with latexmk and TeXShop.

Postby Herbert Schulz » Fri Dec 18, 2009 1:22 pm

Howdy,

What is latexmk?

Compiling a tex file that contains cross-references, bibliographic references and/or indexes is a multi-pass process; i.e., you've got to run (pdf/xe)latex multiple times with possible intermediate runs of bibtex and/or makeindex until all references are resolved. The latexmk perl program, rewritten and presently maintained by John Collins, automates this multi-pass process. By default it first runs (pdf/xe)latex on a source file, determines file dependencies by examining the log and aux files produced by the run and then automatically runs bibtex and/or makeindex, if needed, and the correct number of additional runs of (pdf/xe)latex to generate the bibliography, index and cross-references. Recent versions of latexmk also work correctly with many packages that produce nomenclatures, glossaries and multiple bibliographies and indexes; details are in the documentation noted below.

Activating the latexmk Engines in TeXShop.

There is a set of seven engine files to be moved from ~/Library/TeXShop/Engines/Inactive/Latexmk/ (where there is additional documentaion too) two directories up, to ~/Library/TeXShop/Engines/ and then restarting TeXShop if it is already running. All other files used by these engines are already in place.

Using latexmk with TeXShop.

There are seven engine files; two for running latex (one with a final run through dvips and ps2pdf [latexmk.engine] and a second with a final run through dvipdfmx [dvipdfmxmk.engine]), one for using pdflatex [pdflatexmk.engine], one for xelatex [xelatexmk.engine], two for using the pdftricks or pst-pdf packages with pdflatex [pdftricksmk.engine or pst-pdfmk.engine respectively] and one [aysmptotemk.engine] for processing asymptote inclusions.

You can use these engine files by using the drop down menu on the source tool bar or placing the line

% !TEX TS-program = pdflatexmk

(for using pdflatex---similar lines for latex, xelatex, etc.) at the top of your document; then simply using Typeset (Cmd-T}) will automatically run the proper engine. Using latexmk with the pdftricks and pst-pdf packages is discussed in the documentation supplied. Most packages will work ``out of the box'' but some packages that produce files with custom extensions may require some special handling; The usual cases have been taken into account but, again, see the documentation for more details.
Good Luck,
Herb Schulz
Herbert Schulz
 
Posts: 1489
Joined: Thu May 12, 2005 2:31 pm

Re: Automating Multi-Pass Processing with latexmk and TeXSho

Postby Herbert Schulz » Sun Feb 28, 2010 6:17 pm

Howdy,

While the latexmk version (4.13a) hasn't changed, the structure and organization of the files and engines for using latexmk with TeXShop has changed. Instead of a set of files placed directly in the ~/Library/TeXShop/bin/ folder they are now placed in a sub-folder, tslatexmk, of that directory. Also, most of the configuration that you might do (e.g., for custom glossaries using the glossaries package) is now stored in a file, latexmkrcedit, common to all of the engines, created in ~/Library/TeXShop/bin/ the first time you run any of the new engines (which are to be placed in ~/Library/TeXShop/Engines/). The original rc files are not disturbed so you can copy changes you made to them into the latexmkrcedit file. Once you have the new setup running you may remove the rc files, the two .sh files and even the latexmk program from the ~/Library/TeXShop/bin/ folder since they will not be used by the new engines.

Starting with the next release of TeXShop (2.32) any updates to the files in ~/Library/TeXShop/bin/tslatexmk/ will happen automatically when a new version of TeXShop is installed. Except for possible updates to the latexmk program itself and additional engines (e.g., one that uses latex->dvipdfmx was added in the last release) I expect those files to be stable.

You can get the update, with instructions for installing and using it, as Latexmk413aTeXShopV2.zip, from <http://public.me.com/herbs2>. I know that there are sections of that documentation that are rather technical but you need only read the ``What is here?'' section for installation instructions and the ``Using latexmk with TeXShop'' section to get started using the engines.
Good Luck,
Herb Schulz
Herbert Schulz
 
Posts: 1489
Joined: Thu May 12, 2005 2:31 pm

Re: Automating Multi-Pass Processing with latexmk and TeXSho

Postby realbrain » Thu Jul 01, 2010 2:07 pm

Hey,

If been playing around with the pdflatexmk engine.
It work's quite good.
But now I have the Problem that, even if the .tex document has changed because I altered some of the citation, TeXShop does not reload the pdf Preview after complation with pdflatexmk has finished.
This is really a usability-killer for me.
Is there a Way to fix this?

Regards,
Johannes
realbrain
 
Posts: 1
Joined: Thu Jul 01, 2010 2:01 pm

Re: Automating Multi-Pass Processing with latexmk and TeXSho

Postby Herbert Schulz » Thu Jul 01, 2010 3:12 pm

Howdy,

Does the file re-compile at all or does latexmk ``say'' that nothing has changed? If the latter one thing you can do to force it to compile is to clean out all the files (File->Trash Aux Files (Ctl-Cmd-A)) which should delete extraneous file including the file latexmk builds to keep track of file changes.

Also, are you including graphics or anything else that you are changing?

EDIT: By the way, I've been playing with this a bit and, unless I'm not understanding what you are doing, I see no problems. It is possible that changing a citation can lead to identical numbering with a change in the bibliography or a change in numbering or both.
Good Luck,
Herb Schulz
Herbert Schulz
 
Posts: 1489
Joined: Thu May 12, 2005 2:31 pm

Re: Automating Multi-Pass Processing with latexmk and TeXSho

Postby champoll » Wed Jul 21, 2010 8:55 pm

Hello,

I have what looks like the same problem as Johannes. Often, when I compile a document in Texshop using latexmk or pdflatexmk and when the preview window is already open, the error console tells me that compilation proceeds correctly (i.e. it ends with "For rule 'ps2pdf, running &do_viewfile()' ... Latexmk: All targets (main.pdf main.ps main.dvi) are up-to-date"), but the Texshop pdf preview window doesn't register the change, that is, it doesn't update itself to show the output of the compilation. I know that compilation proceeds correctly: after compiling, if I I manually close and re-open the document preview, I can see that whatever changes I've made to the document have been compiled into the pdf.

This is a big problem for me as well because manually closing and reopening the preview window takes a lot of time. And it is a specific problem to latexmk, because when I select latex or pdflatex as my compilation engine, the preview window refreshes correctly.
champoll
 
Posts: 8
Joined: Wed Apr 16, 2008 5:46 pm

Re: Automating Multi-Pass Processing with latexmk and TeXSho

Postby Herbert Schulz » Wed Jul 21, 2010 10:28 pm

Howdy,

I'm not sure what is giving rise to your problems. As stopgap you might try to clean out the files; use TeXShop's File->Trash Aux Files (Ctl-Cmd-A) which, with recent versions of TeXshop will also remove latexmk's database file. It will be a full rebuild but that should clear up the problem. What version of TeXShop and latexmk are you using? (The TeXShop version should be in TeXShop->About TeXShop and the latexmk version should be on the first line of the Console output when you use one of the latexmk engines.)

If you run across this again I'd like to get a copy of all the files and a short document of the changes you made that didn't generate the new files so I and John Collins (the maintainer of latexmk) could see what is happening.

Finally, should the changes you made to the document show on the page that was displayed. Sounds silly but I've seen that happen.
Good Luck,
Herb Schulz
Herbert Schulz
 
Posts: 1489
Joined: Thu May 12, 2005 2:31 pm

Re: Automating Multi-Pass Processing with latexmk and TeXSho

Postby champoll » Wed Jul 21, 2010 11:43 pm

Hello,

I'm using Latexmk 16 January 2010, version: 4.13a, and Texshop version 2.36. I think I found the solution to my problem. It seems that the problem had to do with a warning by latexmk that was output after the line
Code: Select all
"For rule 'ps2pdf', running '&do_viewfile(  )' ..."
. This warning came from Bibtex and went something like the following:

Code: Select all
A bad cross reference---entry "link87"
refers to entry "gardenfors87", which doesn't exist


I fixed my Bibtex file, tinkered with it and deleted the associated files (the entry gardenfors87 did exist, so I don't know exactly what I did), and now the bibtex error no longer occurs, and the texshop preview is refreshed correctly. (Unfortunately that also means that I can't reproduce the error...)

The console output now ends with:

Code: Select all
For rule 'ps2pdf', running '&do_viewfile(  )' ...
Latexmk: All targets (main.pdf main.ps main.dvi) are up-to-date


I don't know the inner workings of the latexmk plugin, but is it possible that the output of latexmk is scanned for the &do_viewfile( ) command in order to determine when to refresh? In this case the output of additional error messages afterwards might have interfered with the refresh.
champoll
 
Posts: 8
Joined: Wed Apr 16, 2008 5:46 pm

Re: Automating Multi-Pass Processing with latexmk and TeXSho

Postby Herbert Schulz » Wed Jul 21, 2010 11:50 pm

Howdy,

Hmmm... That seems strange to me. I thought TeXShop 2.36 shipped with latexmk 4.17 which should have overwritten the older version automatically.

You can get latexmk 4.17 and other updated files as Latexmk417TeXShop.zip from <http://public.me.com/herbs2>. Installation instructions are supplied.
Good Luck,
Herb Schulz
Herbert Schulz
 
Posts: 1489
Joined: Thu May 12, 2005 2:31 pm

Re: Automating Multi-Pass Processing with latexmk and TeXSho

Postby champoll » Thu Jul 22, 2010 12:05 am

Hello,

I found out why I was still using the older version of latexmk. Apparently the location of latexmk was moved from Library/Texshop/bin/ to .../bin/txlatexmk. I had manually replaced the latexmk binary in bin by its then most recent version at some point. Even though I later updated my Texshop, my latexmk.engine file didn't update and it still pointed to the old location of latexmk. I deleted the bin and Engine folders and let Texshop regenerate them. All is well now.

Thanks for your prompt replies!
champoll
 
Posts: 8
Joined: Wed Apr 16, 2008 5:46 pm

Re: Automating Multi-Pass Processing with latexmk and TeXSho

Postby Herbert Schulz » Thu Jul 22, 2010 12:25 am

Howdy,

I think that transition came about around version 2.30 (or was that 2.33?) of TeXShop. it is important to get into the habit of reading the Help->About This Release document with each new release of TeXShop. There are often things that must be updated manually. The design was such that things didn't stop working if you didn't update the engines but you didn't get to use the new file layout. TeXShop will never automatically update items directly in the Engines folder since you may have customized some of them but things in the Engines/Inactive folder can be updated. You need to read that document to find out.

Hope all goes smoothly now.
Good Luck,
Herb Schulz
Herbert Schulz
 
Posts: 1489
Joined: Thu May 12, 2005 2:31 pm

Next

Return to TeXShop (engl.)

Who is online

Users browsing this forum: No registered users and 1 guest

cron