Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Hot answers tagged

79

(As the author of latexmk, I am naturally partial to my own program, but here's my 2-cents' worth anyway.) The fundamental problem that latexmk solves is that the number of runs of (pdf)latex needed is highly dynamically dependent on the document and the class file used. If you make a small change to a document, often only one recompilation by (pdf)latex ...


66

At Hans-Peter E. Kristiansen’s request, I provide another answer, extending the one given by kay102. Add the following lines to some latexmk initialization file (e.g., on Linux systems, ~/.latexmkrc): add_cus_dep('glo', 'gls', 0, 'run_makeglossaries'); add_cus_dep('acn', 'acr', 0, 'run_makeglossaries'); sub run_makeglossaries { if ( $silent ) { ...


58

Evince and Okular will auto-reload when the file being viewed changes. So does another option: Zathura. That said, my recommendation would still be MuPDF instead, though it'll take some more work to set up. The reason is that MuPDF in general is a much faster program, and will reload faster. It doesn't auto reload like these do, but this can be solved. I ...


51

You can use Lua(La)TeX with latexmk by setting the -pdflatex parameter: -pdflatex=<program> - set program used for pdflatex. (replace '<program>' by the program name) So latexmk should call lualatex instead of pdflatex if you invoke it like this: latexmk -pdflatex=lualatex -pdf <texfile> or with newer versions ...


45

You need to write a configuration file that tells latexmk which files are interesting for the glossary and how to handle them. Fortunately, the author provides some sample rc files. Putting add_cus_dep('glo', 'gls', 0, 'makeglo2gls'); sub makeglo2gls { system("makeindex -s '$_[0]'.ist -t '$_[0]'.glg -o '$_[0]'.gls '$_[0]'.glo"); } in ~/.latexmkrc (...


40

As this is still very high on google: LatexMk (since 4.31) supports the -xelatex option and auto-detects biber. Therefore, in the fabulous world of 2015: $ latexmk -xelatex biberedtexfile.tex works fine.


40

Unfortunately, rubber does not seem to be really maintained anymore; the latest stable version 1.1 was released in 2006, and the more recent "development version" is unusable. That's the main reason why I tried to switch from rubber to latexmk. However, it seems that the rubber has the following features that are not (yet?) offered by latexmk: Rubber ...


25

As of May 17, 2012, the external lib comes with support for both checksum checks and diff-based checks (CVS version at the time of this writing). With this version, the picture's content is compared against the state of the most recent successfull image externalization. Changes in the picture's content will automatically cause a remake for both mode=list ...


23

"precompile" is probably a slightly confusing phrase to use as TeX is not a compiler but (mostly) a macro expansion language, but anyway... In general you can dump most macro definitions and register assignments into a format. What you can't do is ship out pages. So in practice you can dump most LaTeX preambles. Rather than having to edit the file so that ...


22

One important advantage of latexmk over rubber is that latexmk detects dependent files much more reliably. As best as I have been able to work out, rubber determines the dependent files by parsing the tex file, by looking for \input, \include and \includegraphics macros. But if these macros are buried inside another macro, rubber doesn't detect the ...


22

Yes, you can use latexmk -C (or -c) just to clean up auxiliary files. By default, -c cleans up the following files types: @generated_exts = ( 'aux', 'bcf', 'fls', 'idx', 'ind', 'lof', 'lot', 'out', 'toc' ); (latexmk.pl, l. 1088f) -C also cleans up the actual output, i.e pdf, dvi, or what have you. If you want to add more file extensions ...


22

A simpler solution is latexmk -pvc -pdf -xelatex -interaction=nonstopmode foo.tex


22

You need $pdf_mode = 1; to enable pdf mode. The manual says it is the same as the option: ... Equivalent to the -pdf-, -pdf, -pdfdvi, -pdfps options. As of 17 August 2016, latexmk follows the XDG Base Directory Specification and looks for its configuration file in $XDG_CONFIG_HOME/latexmk/latexmkrc (or $HOME/.config/latexmk/latexmkrc if the $...


20

By default, latexmk treats .bbl files as non-regeneratable. This is because the .bib from which they are made is not always available. See the documentation for a fuller explanation, especially the explanation of the $bibtex_use variable. To get latexmk -C to delete .bbl files, put the following in an initialization file: $bibtex_use = 2;


19

As announced at Use MiKTeX option through latexmk, I've made a new version of latexmk, which supports -output-directory. It's v. 4.27a and can be found at http://www.phys.psu.edu/~collins/latexmk/versions.html (It'll be on CTAN soon.) Just use the following settings in your latexmkrc file $pdflatex="pdflatex -interaction=nonstopmode %O %S"; $out_dir = '...


19

I've made a new version of latexmk, which supports -aux-directory and -output-directory. It's v. 4.27a and can be found at http://www.phys.psu.edu/~collins/latexmk/versions.html This version will be submitted to CTAN fairly soon, but some feedback would be useful, since I have not tested the new features extensively, especially as I don't have current ...


19

Latexmk also brings an auto-preview feature, which recompiles (smartly) the pdf as soon as the tex is saved. There are also more advanced features, like tight integration with makefiles for example.


17

You can use latexmk's -jobname option like this: latexmk -pdf -jobname=/path/to/new/output/newfilename currentfile and all of the output files will be routed to the directory specified and given the basename 'newfilename'. E.g., all the files associated with processing currentfile.tex will now be in output/ and be called newfilename.pdf, newfilename.bbl, ...


16

The most commonly used are Evince and Okular (whether you are respectively using GNOME/XFCE or KDE).


16

If you look carefully at the output from the run, you'll see that on the first run, pdflatex detects a first missing file. Since nonstopmode is being used, that causes a fatal error, and pdflatex goes no further. Then latexmk sees a message about a single missing file, makes it, and repeats the run. Then an error comes up about the second missing file, ...


16

Let my try to solve your issue using arara If you hear arara the first time here a small abstract: arara allows the specification of the compilation steps from the main document This small sentence isn't able to describe the whole power of the tool. Therefor you can have a look at the documentation or the short intro at the homepage: Homepage arara The ...


15

The reason latexmk keeps re-running is because the generated a-pics.pdf file keeps changing on every run. There are lines in the PDF file with creation dates, modification dates and IDs that keep changing. There are at least two possible solutions. Tell latexmk to ignore a-pics.pdf completely from its dependency database. There does not currently seem to be ...


14

What you forgot is that a custom dependency is intended to have input and output files that differ only in their extensions, e.g., to convert foo.ltx to foo.fmt. But they don't work to convert, for example, fmt/preamble.tex to main.fmt. A second, but less severe, problem is that when pdfLaTeX doesn't find the .fmt file, it dies with an error message to the ...


13

Put $pdflatex=q/xelatex -synctex=1 %O %S/ in the .latexmkrc file. For Biber, look at this discussion. However the latest version of latexmk coming with TeX Live 2011 works with Biber, choosing it automatically when needed (thanks to PLK for pointing this out).


13

You can get automatic updating with xpdf by setting the following in ~/.latexmkrc: $pdf_previewer = "start xpdf -remote %R %O %S"; $pdf_update_method = 4; $pdf_update_command = "xpdf -remote %R -reload"; These settings are straight out of the latexmk documentation. I've found this works very well, and is my preferred solution at the moment. It has the ...


13

This is a quite general question, and so it'll be hard to write down a complete answer. I'll talk about when I use Make and when I use latexmk. latexmk is a tool for compiling .tex files, and not much else. However, it's good at determining which files depend on which other files: you don't need to provide a list, so latexmk main will only recompile when a ...


12

You can use pplatex to filter errors, warnings and badboxes: http://www.stefant.org/web/projects/software/pplatex.html (the compilation of http://dl.dropbox.com/u/12697903/pplatex/pplatex-1.0-rc1-src.tar.gz needs an additional #include in src/outputfilter.cpp) If you then have ppdflatex in the path, you can create a ~/.latexmkrc file like the following to ...


12

I agree that many of latexmk's messages should not appear when the -quiet option is used. The messages about undefined messages really are only needed for the last run; but implementing that would need some changes in the logic. I'll add that to the list of improvements. Also it might be worth having a super-quiet mode as well as a quiet mode. Super-...


12

Another option to the presumably canonical answer John gave is specifying $clean_ext in a latexmkrc file, which contains your personalized global options. This file can be in one of the places I outlined in my answer to Latexmk: makeglossaries, Biber and pdfLaTeX / Where to put latexmkrc?. Also see the latexmk manual. My complete list of extensions looks ...


12

Here's a little perl script that might get you started. You can use it as perl removelatexcode.pl myfile.tex myfile1.tex and can call it with as many files as you like (or you could pipe into it too). It does the following: copies your input file, myfile.tex to myfile.tex.bak just in case something goes wrong loops through each line in the file, and ...


Only top voted, non community-wiki answers of a minimum length are eligible