### Latexmk Command Specification Examples Source: https://context7.com/debian-tex/latexmk/llms.txt Examples of how to define custom commands for external tools like dvips, ps2pdf, and bibtex within latexmk configuration. These examples demonstrate the use of placeholders for options, input, and output files. ```shell $dvips = 'dvips %O -o %D %S'; ``` ```shell $ps2pdf = 'ps2pdf -dALLOWPSTRANSPARENCY %O %S %D'; ``` ```shell $bibtex = 'bibtex %O %Y%R'; ``` -------------------------------- ### Integrate Latexmk with Makefile Source: https://context7.com/debian-tex/latexmk/llms.txt Provides an example Makefile that utilizes latexmk for compiling a PDF document and includes rules for building and cleaning. It demonstrates how to use generated dependency files. ```makefile # Example Makefile integration DOCUMENT = thesis LATEXMK = latexmk -pdf .PHONY: all clean all: $(DOCUMENT).pdf $(DOCUMENT).pdf: $(DOCUMENT).tex $(LATEXMK) $(DOCUMENT) -include $(DOCUMENT).deps clean: $(LATEXMK) -C $(DOCUMENT) ``` -------------------------------- ### Generate Make Dependencies with Latexmk Source: https://context7.com/debian-tex/latexmk/llms.txt Shows how to use latexmk to generate dependency files in a format compatible with GNU Make. This is useful for integrating LaTeX compilation into larger build systems. ```bash # Generate dependencies in make format latexmk -pdf -M -MF thesis.deps thesis.tex # Include phony targets for robustness latexmk -pdf -M -MP -MF thesis.deps thesis.tex # Use make for missing files latexmk -pdf -use-make thesis.tex ``` -------------------------------- ### Output Directory Configuration Source: https://context7.com/debian-tex/latexmk/llms.txt Manage where build artifacts and auxiliary files are stored by specifying output and auxiliary directories. ```bash latexmk -pdf -outdir=build thesis.tex latexmk -pdf -auxdir=aux -outdir=output thesis.tex latexmk -pdf -cd /path/to/documents/thesis.tex latexmk -pdf -dir-report thesis.tex ``` -------------------------------- ### Configure Latexmk Build Options Source: https://context7.com/debian-tex/latexmk/llms.txt Sets up custom commands for pdflatex, configures output and auxiliary directories, and defines cleanup extensions. It also controls silent operation and time display. ```perl $pdflatex = 'pdflatex --shell-escape %O %S'; $pdf_previewer = 'start evince %O %S'; $out_dir = 'build'; $aux_dir = 'build/aux'; $clean_ext = 'synctex.gz run.xml bbl bcf fdb_latexmk'; $sleep_time = 1; $show_time = 1; $silent = 0; ``` -------------------------------- ### Continuous Preview Mode Source: https://context7.com/debian-tex/latexmk/llms.txt Utilize the -pvc flag to monitor source files for changes and trigger automatic recompilation, useful for live document development. ```bash latexmk -pdf -pvc thesis.tex latexmk -xelatex -pvc thesis.tex latexmk -pdf -pvc -view=pdf thesis.tex latexmk -pdf -pvc -view=none thesis.tex latexmk -pdf -pvc -pvctimeout thesis.tex ``` -------------------------------- ### Latexmk Command Placeholders Reference Source: https://context7.com/debian-tex/latexmk/llms.txt Lists and explains the common placeholders used in latexmkrc configuration files for dynamic command substitution during compilation. ```perl # In latexmkrc: Placeholder usage examples # %S = source file # %D = destination file # %B = base name of current command # %R = root filename (affected by -jobname) ``` -------------------------------- ### Configure PDF Previewers in Latexmk Source: https://context7.com/debian-tex/latexmk/llms.txt Sets the default PDF viewer for different operating systems (Linux, macOS, Windows) and configures how the viewer is updated. It also includes settings for PostScript and DVI viewers. ```perl # Linux with evince $pdf_previewer = 'start evince %O %S'; # Linux with okular $pdf_previewer = 'start okular %O %S'; # macOS with Preview $pdf_previewer = 'open -a Preview %O %S'; # macOS with Skim (with auto-reload) $pdf_previewer = 'open -a Skim %O %S'; # Windows with SumatraPDF $pdf_previewer = 'start "c:/Program Files/SumatraPDF/SumatraPDF.exe" %O %S'; # Configure viewer update method # 0 = no update, 1 = windowing system, 2 = signal, 4 = run command $pdf_update_method = 0; # PostScript viewer $ps_previewer = 'start gv -watch %O %S'; # DVI viewer $dvi_previewer = 'start xdvi %O %S'; ``` -------------------------------- ### RC File Configuration Source: https://context7.com/debian-tex/latexmk/llms.txt Define persistent project-wide settings using Perl syntax in an initialization file. ```perl $pdf_mode = 1; $postscript_mode = 0; $dvi_mode = 0; ``` -------------------------------- ### Cleanup and Dependency Management Source: https://context7.com/debian-tex/latexmk/llms.txt Commands to remove generated auxiliary files or export dependency lists for external build systems like Make. ```bash latexmk -c latexmk -C latexmk -gg -pdf thesis.tex latexmk -pdf -deps thesis.tex latexmk -pdf -deps -deps-out=dependencies.mk thesis.tex ``` -------------------------------- ### Configure Printing Settings in Latexmk Source: https://context7.com/debian-tex/latexmk/llms.txt Defines the output format for printing (PDF, PS, DVI) and specifies the commands used for sending documents to the printer. It also includes options for adding a banner message to PostScript output. ```perl # Set print type (auto, dvi, ps, pdf) $print_type = 'pdf'; # Configure print commands $lpr = 'lpr %O %S'; # PostScript printer $lpr_dvi = 'NONE'; # No DVI printing $lpr_pdf = 'lpr %O %S'; # PDF printer # Print banner message across pages (PostScript only) $banner = 1; $banner_message = 'DRAFT'; $banner_scale = 220.0; $banner_intensity = 0.95; ``` -------------------------------- ### BibTeX and Biber Configuration Source: https://context7.com/debian-tex/latexmk/llms.txt Control the behavior of bibliography processing tools during the compilation sequence. ```bash latexmk -pdf -bibtex thesis.tex latexmk -pdf -bibtex- thesis.tex latexmk -pdf -bibtex-cond thesis.tex ``` -------------------------------- ### Basic LaTeX Document Compilation Source: https://context7.com/debian-tex/latexmk/llms.txt Commands to compile LaTeX source files into various formats like DVI, PDF, or PostScript using different engines such as pdflatex, xelatex, and lualatex. ```bash latexmk thesis latexmk -pdf thesis latexmk -xelatex thesis latexmk -lualatex thesis latexmk -pdf -pv thesis.tex latexmk -pdfps thesis ``` -------------------------------- ### Force Recompilation Source: https://context7.com/debian-tex/latexmk/llms.txt Force latexmk to ignore existing build states and perform a fresh compilation of the document. ```bash latexmk -pdf -g thesis.tex latexmk -pdf -gt thesis.tex latexmk -pdf -gg thesis.tex latexmk -pdf -f thesis.tex ``` -------------------------------- ### Configure Bib2gls for Glossaries-Extra Source: https://context7.com/debian-tex/latexmk/llms.txt Integrates the bib2gls tool with latexmk for managing glossaries using the glossaries-extra package. It defines custom dependencies and handles the bib2gls command execution. ```perl push @generated_exts, 'glg', '%R*.glstex'; add_cus_dep('aux', 'glstex', 0, 'run_bib2gls'); sub run_bib2gls { my $ret = 0; my ($base, $path) = fileparse($_[0]); my @bib2gls_cmd = ( "--tex-encoding", "UTF-8", "--log-encoding", "UTF-8", "--group", "--dir", $path, $base ); if ($silent) { unshift @bib2gls_cmd, "--silent"; } unshift @bib2gls_cmd, "bib2gls"; print "Running '@bib2gls_cmd'... "; $ret = system @bib2gls_cmd; return $ret; } ``` -------------------------------- ### Latexmk Configuration Variables in Perl Source: https://context7.com/debian-tex/latexmk/llms.txt Common configuration variables used in a latexmkrc file to customize the behavior of latexmk. This includes settings for output modes (PDF, DVI, PostScript), command specifications for various compilers and tools, BibTeX usage, preview settings, file handling, and silent mode switches. ```perl # Output mode settings $pdf_mode = 1; $dvi_mode = 0; $postscript_mode = 0; # Command specifications $latex = 'latex %O %S'; $pdflatex = 'pdflatex %O %S'; $lualatex = 'lualatex %O %S'; $xelatex = 'xelatex %O %S'; $bibtex = 'bibtex %O %S'; $biber = 'biber %O %S'; $makeindex = 'makeindex %O -o %D %S'; $dvips = 'dvips %O -o %D %S'; $dvipdf = 'dvipdf %O %S %D'; $ps2pdf = 'ps2pdf %O %S %D'; # Bibtex behavior: 0=never, 1=if bib exists, 1.5=conditional, 2=always $bibtex_use = 1; # Preview settings $preview_mode = 0; $preview_continuous_mode = 0; # File handling $recorder = 1; $cleanup_mode = 0; # Extensions for cleanup $clean_ext = ''; $clean_full_ext = ''; @generated_exts = ('aux', 'bbl', 'bcf', 'blg', 'fdb_latexmk', 'fls', 'idx', 'ilg', 'ind', 'log', 'out', 'run.xml', 'toc'); # Default files to process @default_files = ('*.tex'); # Silent mode switches $latex_silent_switch = '-interaction=batchmode'; $pdflatex_silent_switch = '-interaction=batchmode'; $bibtex_silent_switch = '-terse'; $biber_silent_switch = '--onlylog'; ``` -------------------------------- ### Custom LaTeX Command Overrides Source: https://context7.com/debian-tex/latexmk/llms.txt Override default engine commands or pass custom arguments to the LaTeX compiler via the command line. ```bash latexmk -pdf -pdflatex="pdflatex --shell-escape %O %S" thesis.tex latexmk -pdfxe -xelatex="xelatex --shell-escape %O %S" thesis.tex latexmk -pdf -usepretex='\\AtBeginDocument{DRAFT\\par}' thesis.tex latexmk -e '$pdf_mode=1; $pdflatex="pdflatex -shell-escape %O %S"' thesis.tex ``` -------------------------------- ### Silent Mode and Diagnostic Tools Source: https://context7.com/debian-tex/latexmk/llms.txt Control the verbosity of the output and access diagnostic information to troubleshoot compilation issues. ```bash latexmk -pdf -silent thesis.tex latexmk -pdf -diagnostics thesis.tex latexmk -pdf -logfilewarnings thesis.tex latexmk -pdf -Werror thesis.tex latexmk -commands latexmk -version ``` -------------------------------- ### Define Custom Dependencies with Perl Source: https://context7.com/debian-tex/latexmk/llms.txt Adds custom dependencies to latexmk, allowing it to convert between file formats using external tools like fig2dev, inkscape, and makeglossaries. This enables support for various file types and packages. ```perl add_cus_dep('fig', 'eps', 0, 'fig2eps'); sub fig2eps { system("fig2dev -Leps \"$_[0].fig\" \"$_[0].eps\""); } add_cus_dep('svg', 'pdf', 0, 'svg2pdf'); sub svg2pdf { system("inkscape --export-pdf=\"$_[0].pdf\" \"$_[0].svg\""); } add_cus_dep('acn', 'acr', 0, 'makeglossaries'); add_cus_dep('glo', 'gls', 0, 'makeglossaries'); $clean_ext .= " acr acn alg glo gls glg"; sub makeglossaries { my ($base_name, $path) = fileparse($_[0]); my @args = ("-q", "-d", $path, $base_name); if ($silent) { unshift @args, "-q"; } return system "makeglossaries", "-d", $path, $base_name; } ``` -------------------------------- ### Enable TikZ Externalization with Latexmk Source: https://context7.com/debian-tex/latexmk/llms.txt Configures latexmk to support TikZ externalization, which caches TikZ figures for faster compilation. It modifies cleanup extensions and sets up custom commands for different LaTeX engines. ```perl $clean_ext .= ' %R.figlist %R-figure* %R.makefile fls.tmp'; $latex = 'internal tikzlatex latex %B %O %S'; $pdflatex = 'internal tikzlatex pdflatex %B %O %S'; $lualatex = 'internal tikzlatex lualatex %B %O %S'; $xelatex = 'internal tikzlatex xelatex %B %O %S'; $hash_calc_ignore_pattern{'pdf'} = '^(/CreationDate|/ModDate|/ID)'; $hash_calc_ignore_pattern{'ps'} = '^%%CreationDate'; sub tikzlatex { my ($engine, $base, @args) = @_; my $ret = system($engine, @args); if ($ret) { return $ret; } if (-e "$aux_dir1$base.makefile") { $ret = system "make", "-j", "5", "-f", "$aux_dir1$base.makefile"; } return $ret; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.