Last active
July 22, 2023 20:09
-
-
Save Mearman/d62eb04db69e8c610326507d0c9ad31f to your computer and use it in GitHub Desktop.
.latexmkrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$recorder = 1; | |
$pdf_mode = 1; | |
$bibtex_use = 2; | |
$pdflatex = "pdflatex --shell-escape %O %S"; | |
$pdf_previewer = "start open -a preview %O %S"; | |
add_cus_dep('glo', 'gls', 0, 'run_makeglossaries'); | |
add_cus_dep('acn', 'acr', 0, 'run_makeglossaries'); | |
sub run_makeglossaries { | |
if ( $silent ) { | |
system "makeglossaries -q '$_[0]'"; | |
} | |
else { | |
system "makeglossaries '$_[0]'"; | |
}; | |
} | |
push @generated_exts, 'glo', 'gls', 'glg'; | |
push @generated_exts, 'acn', 'acr', 'alg'; | |
$clean_ext .= ' %R.ist %R.xdy'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Custom dependencies | |
add_cus_dep('glo', 'gls', 0, 'makeglossaries'); | |
add_cus_dep('acn', 'acr', 0, 'makeglossaries'); | |
# pdflatex | |
$pdflatex = 'pdflatex %O %S'; | |
# Biblatex | |
$bibtex = 'biber %O %B'; | |
# Custom command to run before | |
$pre_code = system("shell-command-to-run-before"); | |
# Custom command to run after | |
$post_code = system("shell-command-to-run-after"); | |
# Execution order | |
@default_files = ('main.tex'); | |
$pdf_mode = 1; | |
$pdf_previewer = 'start open -a skim'; | |
$pdf_update_method = 0; | |
$clean_ext = "paux lox toc lb bbl bcf run.xml"; | |
# Run pdflatex, bibtex, makeglossaries and pdflatex again (for bibliography/glossary) | |
$latex = 'internal mylatex %B'; | |
sub mylatex { | |
if (system('pdflatex', @_) != 0) { return 0; } # pdflatex | |
if (system('biber', @_) != 0) { return 0; } # biber | |
if (system('makeglossaries', @_) != 0) { return 0; } # makeglossaries | |
if (system('pdflatex', @_) != 0) { return 0; } # pdflatex | |
return 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$pdflatex = 'pdflatex -synctex=1 -interaction=nonstopmode %O %S'; | |
$bibtex = 'biber %O %S'; | |
$pdf_mode = 1; | |
$clean_ext = 'aux synctex.gz lof log run.xml'; | |
$postscript_mode = 0; | |
$pre_compile_cmd = 'echo "Starting compile"'; | |
$post_compile_cmd = 'echo "Finished compile"'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://man.cx/latexmk | |
$recorder = 1; | |
exit 0; | |
$latex = 'internal mylatex %B'; | |
# default command | |
my @pdflatex_options = ( | |
'pdflatex', | |
'-f', | |
'-file-line-error', | |
'-synctex=1', | |
'-interaction=nonstopmode', | |
'%O %S' | |
); | |
# $pdflatex = join(' ', @pdflatex_options); | |
# $pdflatex = "pdflatex -f -file-line-error -synctex=1 -interaction=nonstopmode %O %S"; | |
$max_repeat = 5; | |
$pdf_mode = 1; | |
# Adjust according to your operating system | |
# For MacOS | |
$pdf_previewer = 'open -a Skim %O %S'; | |
# For Windows | |
# $pdf_previewer = 'start %O %S'; | |
$pdf_update_method = 0; # 0 = default, 1 = copy, 2 = make | |
$interaction = "nonstopmode"; | |
$ENV{"TEXMFHOME"} = "?"; | |
$bibtex_use = 2; | |
my @biber_options = ( | |
'biber', | |
'--nodieonerror', | |
'%O', | |
'%S' | |
); | |
$bibtex = join(' ', @biber_options); # Biber options are now array-based | |
$postscript_mode = 0; | |
add_cus_dep('glo', 'gls', 0, 'makeglossaries'); | |
add_cus_dep('acn', 'acr', 0, 'makeglossaries'); | |
add_cus_dep('glo-abr', 'gls-abr', 0, 'makeglossaries'); | |
push @generated_exts, 'glo', 'gls', 'glg'; | |
push @generated_exts, 'acn', 'acr', 'alg'; | |
push @generated_exts, 'glo-abr', 'gls-abr', 'glg-abr'; | |
@BIBINPUTS=('library.bib'); | |
sub makeglossaries { | |
return system("makeglossaries $_[0]"); | |
} | |
sub mylatex { | |
exit 0; | |
# Perform pdflatex -> biber -> pdflatex -> pdflatex sequence to ensure proper building of bibliography and resolution of references. | |
# pdflatex(@_) or return 0; # pdflatex must be run first | |
# biber(@_) or return 0; # biber must be run after pdflatex | |
# makeglossaries(@_) or return 0; # makeglossaries must be run after biber | |
# pdflatex(@_) or return 0; # pdflatex must be run after biber and makeglossaries | |
# pdflatex(@_) or return 0; # run again to resolve references | |
return 1; # return success | |
} | |
$clean_ext = "paux lox toc lb bbl bcf run.xml aux lof log out acn acr alg glg glo gls ist synctex.gz glg-abr glo-abr gls-abr"; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@default_files = ("main.tex"); | |
# $pdf_update_method = 0; # 0 = default, 1 = copy, 2 = make | |
# $recorder = 1; | |
# $interaction = "nonstopmode"; | |
# $rule{'*'} = []; | |
# $pdflatex = 'pdflatex %O %S'; | |
# $bibtex = 'bibtex %O %S'; | |
# $makeindex = 'makeindex %O -o %D %S'; | |
# $pdf_mode = 1; | |
# $pdf_previewer = 'open %S'; | |
# $pdf_update_method = 4; | |
# $pdf_mode = 1; | |
# $max_repeat = 10; | |
# # pdflatex | |
# $pdflatex = 'pdflatex %O %S'; | |
# # Biblatex | |
# $bibtex = 'biber %O %B'; | |
# # Custom command to run before | |
# $pre_code = system("echo 'starting'"); | |
# # Custom command to run after | |
# $post_code = system("echo 'finished'"); | |
# # Execution order | |
# @default_files = ('main.tex'); | |
# $pdf_mode = 1; | |
# $pdf_previewer = 'start open -a skim'; | |
# $pdf_update_method = 0; | |
# $clean_ext = "paux lox toc lb bbl bcf run.xml"; | |
$latex="internal main"; | |
sub main { | |
system("echo 'start of main'"); | |
# print values of any args | |
system("echo 'args: @_'" ); | |
# exit 1; | |
# exit unless &do_biber_makeglossaries(@_); | |
# exit 0; # exit with 0 to avoid latexmk to run pdflatex | |
# Perform pdflatex -> biber -> pdflatex -> pdflatex sequence to ensure proper building of bibliography and resolution of references. | |
system("echo ; echo '-------------------' ; echo 'pdflatex' ; echo '-------------------' ; echo"); | |
# pdflatex(@_) or return 0; # pdflatex must be run first | |
# if (system('pdflatex -shell-escape', ) != 0) { return 0; } # pdflatex | |
if (system("pdflatex", "-shell-escape %O %S", @_) != 0) { return 0; } # pdflatex | |
system("echo ; echo '-------------------' ; echo 'biber' ; echo '-------------------' ; echo"); | |
# biber(@_) or return 0; # biber must be run after pdflatex | |
system("echo ; echo '-------------------' ; echo 'makeglossaries' ; echo '-------------------' ; echo"); | |
# makeglossaries(@_) or return 0; # makeglossaries must be run after biber | |
system("echo ; echo '-------------------' ; echo 'pdflatex x 1' ; echo '-------------------' ; echo"); | |
# pdflatex(@_) or return 0; # pdflatex must be run after biber and makeglossaries | |
system("echo ; echo '-------------------' ; echo 'pdflatex x 2' ; echo '-------------------' ; echo"); | |
# pdflatex(@_) or return 0; # run again to resolve references | |
system("echo 'end of main'"); | |
# exit 1; | |
# return 1; | |
} | |
# main( @ARGV ); | |
$latexmk = "internal main %B"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://man.cx/latexmk | |
# %A | |
# basename of the main tex file. Unlike %R, this is unaffected by the setting of a jobname by the -jobname option or the $jobname configuration value. | |
# %B | |
# base of filename for current command. E.g., if a postscript file document.ps is being made from the dvi file document.dvi, then the basename is document. | |
# %D | |
# destination file (e.g., the name of the postscript file when converting a dvi file to postscript). | |
# %O | |
# options | |
# %P | |
# If the variable $pre_tex_code is non-empty, then %P is substituted by the contents of $pre_tex_code followed by \input{SOURCE}, where SOURCE stands for the name of the source file. Appropriate quoting is done. This enables TeX code to be passed to one of the *latex engines to be executed before the source file is read. | |
# If the variable $pre_tex_code is the empty string, then %P is equivalent to %S. | |
# %R | |
# root filename. This is the base name for the main tex file. | |
# By default this is the basename of the main tex file. However the value can be changed by the use of the -jobname option or the $jobname configuration variable. | |
# %S | |
# source file (e.g., the name of the dvi file when converting a .dvi file to ps). | |
# %T | |
# The name of the primary tex file. | |
# %U | |
# If the variable $pre_tex_code is non-empty, then its value is substituted for %U (appropriately quoted). Otherwise it is replaced by a null string. | |
# %Y | |
# Name of directory for auxiliary output files (see the configuration variable $aux_dir). A directory separation character (’/’) is appended if $aux_dir is non-empty and does not end in a suitable character, with suitable characters being those appropriate to UNIX and MS-Windows, i.e., ’:’, ’/’ and ’\’. Note that if after initialization, $out_dir is set, but $aux_dir is not set (i.e., it is blank), then latexmk sets $aux_dir to the same value $out_dir. | |
# %Z | |
# Name of directory for output files (see the configuration variable $out_dir). A directory separation character (’/’) is appended if $out_dir is non-empty and does not end in a suitable character, with suitable characters being those appropriate to UNIX and MS-Windows, i.e., ’:’, ’/’ and ’\’. | |
system("echo '========================='"); | |
system("echo"); | |
system("echo 'Starting compile'"); | |
system("echo"); | |
system("echo '========================='"); | |
$recorder = 1; | |
$interaction = "nonstopmode"; | |
$ENV{"TEXMFHOME"} = "?"; | |
$ENV{"BIBINPUTS"} = "library,bib"; | |
$pre_compile_cmd = 'echo "Starting compile"'; | |
@default_files = ("main.tex"); | |
$max_repeat = 5; | |
$pdf_mode = 1; | |
# run biber system command | |
add_cus_dep('glo', 'gls', 0, 'makeglossaries'); | |
add_cus_dep('acn', 'acr', 0, 'makeglossaries'); | |
add_cus_dep('glo-abr', 'gls-abr', 0, 'makeglossaries'); | |
sub makeglossaries { | |
return system("makeglossaries $_[0]"); | |
} | |
$post_compile_cmd = 'echo "Finished compile"'; | |
# 0: never use BibTeX or biber; never delete .bbl files in a cleanup. | |
# 1: only use bibtex or biber if the bib files exist; never delete .bbl files in a cleanup. | |
# 1.5: only use bibtex or biber if the bib files exist; conditionally delete .bbl files in a cleanup (i.e., delete them only when the bib files all exist). | |
# 2: run bibtex or biber whenever it appears necessary to update the bbl files, without testing for the existence of the bib files; always delete .bbl files in a cleanup. | |
# Note that the value 1.5 does not work properly if the document uses biber instead of bibtex. (There's a long story why not.) | |
$bibtex_use = 1; | |
# Define command to compile with pdfsync support and nonstopmode | |
# $pdflatex = 'pdflatex -synctex=1 --interaction=nonstopmode -file-line-error'; | |
$pdflatex = 'echo "bailing" ; exit()'; | |
# Use default pdf viewer (Skim) | |
$pdf_previewer = 'open'; | |
$pdf_update_method = 0; # 0 = default, 1 = copy, 2 = make | |
# Also remove pdfsync files on clean | |
$clean_ext = 'pdfsync synctex.gz'; | |
# $bibtex = 'biber %O --bblencoding=utf8 -u -U --safeinput --output_format=bibtex %B'; | |
sub run_makeglossaries { | |
return system("makeglossaries", "main"); | |
} | |
sub build_process { | |
system("pdflatex main.tex"); | |
run_biber; | |
run_makeglossaries; | |
system("pdflatex main.tex"); | |
system("pdflatex main.tex"); | |
} | |
$latex = 'build_process'; | |
system("echo 'Ending the build process'"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
system("echo '========================='"); | |
system("echo"); | |
system("echo 'Starting Latexmk'"); | |
@default_files = ("main.tex"); | |
$pdf_update_method = 0; # 0 = default, 1 = copy, 2 = make | |
$interaction = "nonstopmode"; | |
$recorder = 1; | |
$pdf_mode = 1; | |
$max_repeat = 10; | |
# enable shell | |
# $shell_escape = 1; | |
# $bibtex_use = 2; | |
$bibtex_silent_switch = "-terse"; | |
# $interaction = "nonstopmode"; | |
# # For MacOS | |
# $pdf_previewer = 'open -a Skim %O %S'; | |
# # For Windows | |
# # $pdf_previewer = 'start %O %S'; | |
# $pdf_update_method = 0; # 0 = default, 1 = copy, 2 = make | |
$bibtex="biber --nodieonerror %O %S"; | |
$latexmk = "latexmk -f -interaction=nonstopmode %O %S"; | |
$pdflatex = "pdflatex -interaction=nonstopmode %O %S"; | |
# $pdflatex = "pdflatex -file-line-error -synctex=1 -shell-escape -interaction=nonstopmode %O %S"; | |
# $clean_ext = "paux lox toc lb bbl bcf run.xml aux lof log out acn acr alg glg glo gls ist synctex.gz glg-abr glo-abr gls-abr"; | |
# $max_repeat = 5; | |
# $pdf_mode = 1; | |
# $ENV{"TEXMFHOME"} = "?"; | |
# $ENV{"BIBINPUTS"} = "library,bib"; | |
# # ============================================================================== | |
# # https://www.ctan.org/tex-archive/support/latexmk | |
# # ============================================================================== | |
add_cus_dep( 'acn', 'acr', 0, 'makeglossaries' ); | |
add_cus_dep( 'glo', 'gls', 0, 'makeglossaries' ); | |
$clean_ext .= " acr acn alg glo gls glg"; | |
# http://mirrors.ctan.org/support/latexmk/example_rcfiles/glossary_latexmkrc | |
# http://mirrors.ctan.org/support/latexmk/example_rcfiles/glossaries_latexmkrc | |
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; | |
} | |
push @generated_exts, 'acn', 'acr', 'alg', 'glg', 'glo', 'gls', 'ist'; | |
# ============================================================================== | |
# # makeindex | |
# add_cus_dep( 'idx', 'ind', 0, 'run_makeindex' ); | |
# add_cus_dep( 'nlo', 'nls', 0, 'run_makeindex' ); | |
# $clean_ext .= " ind idx ilg nls nlo"; | |
# sub run_makeindex { | |
# my ($base_name, $path) = fileparse( $_[0] ); | |
# my @args = ( "-q", "-s", "$path$base_name.ist", "-t", "$path$base_name.alg", "-o", "$path$base_name.acr", "$path$base_name.acn" ); | |
# if ($silent) { unshift @args, "-q"; } | |
# return system "makeindex", @args; | |
# } | |
# # ============================================================================== | |
# # https://anorien.csc.warwick.ac.uk/mirrors/CTAN/support/latexmk/example_rcfiles/bib2gls_latexmkrc | |
# push @generated_exts, 'glstex', 'glg'; | |
# add_cus_dep('aux', 'glstex', 0, 'run_bib2gls'); | |
# $clean_ext .= ' glstex glg'; | |
# sub run_bib2gls { | |
# if ( $silent ) { | |
# my $ret = system "bib2gls --silent --group '$_[0]'"; | |
# } else { | |
# my $ret = system "bib2gls --group '$_[0]'"; | |
# }; | |
# my ($base, $path) = fileparse( $_[0] ); | |
# if ($path && -e "$base.glstex") { | |
# rename "$base.glstex", "$path$base.glstex"; | |
# } | |
# # Analyze log file. | |
# local *LOG; | |
# $LOG = "$_[0].glg"; | |
# if (!$ret && -e $LOG) { | |
# open LOG, "<$LOG"; | |
# while (<LOG>) { | |
# if (/^Reading (.*\.bib)\s$/) { | |
# rdb_ensure_file( $rule, $1 ); | |
# } | |
# } | |
# close LOG; | |
# } | |
# return $ret; | |
# } | |
# push @generated_exts, 'glstex', 'glg'; | |
# # ============================================================================== | |
# # Arbitrary shell command at the start | |
# system("echo"); | |
# system("echo 'Starting compile'"); | |
# sub compile { | |
# system("echo '========================='"); | |
# system("echo"); | |
# system("echo 'Compiling'"); | |
# system("echo"); | |
# # run pdflatex | |
# # system("pdflatex -file-line-error -synctex=1 -shell-escape -interaction=nonstopmode main.tex"); | |
# } | |
# # Arbitrary shell command at the end | |
# system("echo 'Ending the build process'"); | |
# system("pdflatex") | |
$latex = 'internal mylatex %B'; | |
sub mylatex { | |
# exit unless &do_biber_makeglossaries(@_); | |
exit 0; # exit with 0 to avoid latexmk to run pdflatex | |
# Perform pdflatex -> biber -> pdflatex -> pdflatex sequence to ensure proper building of bibliography and resolution of references. | |
pdflatex(@_) or return 0; # pdflatex must be run first | |
biber(@_) or return 0; # biber must be run after pdflatex | |
makeglossaries(@_) or return 0; # makeglossaries must be run after biber | |
pdflatex(@_) or return 0; # pdflatex must be run after biber and makeglossaries | |
pdflatex(@_) or return 0; # run again to resolve references | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment