Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
198 views
ubuntu2404
# Computational Chemistry LaTeX Template - latexmkrc Configuration
# Optimized for CoCalc with PythonTeX support
# Keywords: latexmkrc pythontex, computational chemistry latex config

# Use pdflatex as the default engine
$pdf_mode = 1;
$pdflatex = 'pdflatex -shell-escape -interaction=nonstopmode -halt-on-error %O %S';

# Enable shell escape for PythonTeX, minted, and molecular visualization packages
$latex = 'latex -shell-escape -interaction=nonstopmode -halt-on-error %O %S';
$pdflatex = 'pdflatex -shell-escape -interaction=nonstopmode -halt-on-error %O %S';

# PythonTeX configuration for computational chemistry calculations
add_cus_dep('pytxcode', 'pytxmcr', 0, 'pythontex');
add_cus_dep('pytxmcr', 'pytxpyg', 0, 'pythontex');

sub pythontex {
    my $base = $File::Find::dir . '/' . $_[0];
    return system("pythontex \"$base\"");
}

# Output directory for build files
$out_dir = 'build';

# Ensure assets directory exists for generated figures
system('mkdir -p assets');

# File extensions to clean
$clean_ext = 'pytxcode pytxmcr pytxpyg figlist makestuff pytxpyg synctex.gz';

# Maximum number of LaTeX runs
$max_repeat = 5;

# Auto-generate missing files
$auto_rc_use = 1;

# Preview mode settings for live compilation in CoCalc
$preview_continuous_mode = 1;
$pdf_previewer = 'open %O %S';

# Silence some warnings common in computational chemistry templates
$silence_logfile_warnings = 1;

# Bibtex configuration for chemistry citations
$bibtex_use = 1;
$biber = 'biber %O %S';

# Custom dependencies for molecular structure files
add_cus_dep('mol', 'eps', 0, 'mol2eps');
add_cus_dep('xyz', 'pdf', 0, 'xyz2pdf');

sub mol2eps {
    return system("obabel $_[0].mol -O $_[0].eps");
}

sub xyz2pdf {
    return system("python scripts/xyz2pdf.py $_[0].xyz $_[0].pdf");
}