forked from yax-lakam-tuun/maya-decipherment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Compile-Document.ps1
77 lines (65 loc) · 2.28 KB
/
Compile-Document.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Compiles TeX project into PDF document.
.DESCRIPTION
This script can be used to compile the LaTeX project.
The main TeX file, the build directory and the name of the document can be specified.
If parameters are omitted, useful defaults are taken (see parameter description).
Even sub folders can be compiled into separate PDF file by specifying
the sub folders's TeX file.
If the build path is not specified, a build folder named "build" will be created next to the
TeX file.
.INPUTS
None. You cannot pipe objects into this script.
.OUTPUTS
None. The output is undefined.
.LINK
https://github.com/yax-lakam-tuun/maya-decipherment
#>
[CmdletBinding()]
param (
[string]
# The TeX file to be compiled.
[Parameter(HelpMessage="Enter LaTeX file to compile.")]
$TexFile = "$(Resolve-Path -Path $PSScriptRoot)/main.tex",
[string]
# The path to the TeX source files. Usually the root of a TeX project.
[Parameter(HelpMessage="Enter path in which LaTeX sources are located.")]
$SourcePath="$(Resolve-Path -Path $PSScriptRoot)",
[string]
# The path to the output directory. The final document will be placed there, too.
[Parameter(HelpMessage="Enter path in which output files can be stored.")]
$BuildPath="$(Resolve-Path -Path $(Get-Item $TexFile).Directory)/build",
[string]
# The file name of the PDF document.
[Parameter(HelpMessage="Enter name of the final PDF document.")]
$DocumentName="$((Get-Item $TexFile).BaseName)"
)
function Write-Summary {
Write-Output "Compiling to $BuildPath/$DocumentName.pdf"
Write-Output ""
Write-Output "Settings:"
Write-Output " Name of document: $DocumentName"
Write-Output " Source path: $SourcePath"
Write-Output " Build path: $BuildPath"
Write-Output " Tex file: $TexFile"
Write-Output ""
Write-Output "Invoking latexmk..."
Write-Output ""
}
function Invoke-LaTeX {
Set-Location -Path "$SourcePath"
latexmk `
-cd `
-synctex=1 `
-interaction=nonstopmode `
-file-line-error `
-pdf `
-Werror `
-jobname="$DocumentName" `
-outdir="$BuildPath" `
"$TexFile"
}
Write-Summary
Invoke-LaTeX