# Build PRINCIPAL.pdf (elsarticle, xelatex + biblatex/biber). # Reusable recipe after the tectonic build was found broken in this env. # Usage: powershell -NoProfile -ExecutionPolicy Bypass -File tools\build_pdf.ps1 $ErrorActionPreference = 'Continue' $root = 'c:\Users\fdavalos\OneDrive - up.edu.mx\microtracking\MicrotrackingFer' $art = Join-Path $root 'articulo' # Locate a TeX engine (prefer MiKTeX on PATH, else the known install). function Resolve-Engine($name) { $c = Get-Command $name -ErrorAction SilentlyContinue if ($c) { return $c.Source } $p = "C:\Users\fdavalos\AppData\Local\Programs\MiKTeX\miktex\bin\x64\$name.exe" if (Test-Path $p) { return $p } return $null } $xelatex = Resolve-Engine 'xelatex' $biber = Resolve-Engine 'biber' if (-not $xelatex) { Write-Error 'xelatex not found. Install MiKTeX or add it to PATH.' } Write-Host "xelatex: $xelatex" Write-Host "biber : $biber" Set-Location $art # Drop stale auxiliary files (OneDrive can leave locked/stale aux). Get-ChildItem -File | Where-Object { $_.Name -match '\.(aux|bbl|bblg|bcf|fls|out|toc|nav|snm|run\.xml|xrefs\.tex|makejob)$' } | Remove-Item -Force -ErrorAction SilentlyContinue Write-Host '=== PASS 1 (xelatex) ===' & $xelatex -interaction=nonstopmode -halt-on-error PRINCIPAL Write-Host "PASS1 exit=$LASTEXITCODE bcf=$(Test-Path PRINCIPAL.bcf)" if ((Test-Path PRINCIPAL.bcf) -and $biber) { Write-Host '=== BIBER ===' & $biber PRINCIPAL Write-Host "BIBER exit=$LASTEXITCODE bbl=$(Test-Path PRINCIPAL.bbl)" Write-Host '=== PASS 2 (xelatex) ===' & $xelatex -interaction=nonstopmode PRINCIPAL Write-Host "PASS2 exit=$LASTEXITCODE" Write-Host '=== PASS 3 (xelatex) ===' & $xelatex -interaction=nonstopmode PRINCIPAL Write-Host "PASS3 exit=$LASTEXITCODE" } if (Test-Path PRINCIPAL.pdf) { Write-Host ('PDF mtime: ' + (Get-Item PRINCIPAL.pdf).LastWriteTime) } else { Write-Host 'PDF NOT PRODUCED' } Write-Host '=== BUILD DONE ==='