1 Star 0 Fork 3

善衡/eda

forked from 连享会/eda 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
maketexcomp.ado 4.23 KB
一键复制 编辑 原始数据 按行查看 历史
********************************************************************************
* Description of the Program - *
* Utility to build a LaTeX compilation script. *
* *
* Program Output - *
* Bash/Batch script calling pdflatex on a given LaTeX source code file *
* *
* Lines - *
* 125 *
* *
********************************************************************************
*! maketexcomp
*! v 0.0.5
*! 01may2019
// Drop program from memory if it is already loaded
cap prog drop maketexcomp
// Define program
prog def maketexcomp, rclass
// Version Stata should use to interpret the code
version 14
// Define syntax structure for subroutine
syntax anything(name=filenm id="Name of LaTeX Source Code File"), ///
SCRiptname(string) root(string) [ PDFlatex(string asis) ]
// If path to pdfLaTeX not specified use *nix binary reference
if `"`pdflatex'"' == "" loc pdflatex pdflatex
// Clean the filename macro to remove any quotation marks from the path
loc filenm `: subinstr loc filenm `"""' "", all'
// Check if user is running on Windows
if `"`c(os)'"' == "Windows" {
// Creates file extension for Windows terminal executables
loc extension .bat
// Adds a comment header for Windows batch files
loc header "::Batch file to compile LaTeX source"
// Move to directory
loc dirmove `"chdir /d `root'"'
// Contructs the reference to the pdf LaTeX binary
loc bin `pdflatex'.exe
// Contructs the reference to the terminal command to delete/remove files
loc remove DEL
// Only used for parallel construction across OS
loc scriptexec
} // End of IF Block for Windows systems
// For *nix based systems
else {
// Create extension reference for a shell script
loc extension .sh
// Add the header for the Bourne Again SHell
loc header "#!/bin/bash"
// Move to directory
loc dirmove `"cd `root'"'
// Add reference to the binary for pdf LaTeX
loc bin `pdflatex'
// Add reference for the terminal command to delete/remove files
loc remove "rm"
// Constructs shell command to make the script executable
loc scriptexec ! chmod +x "`scriptname'`extension'"
} // End of ELSE Block for *nix based systems
// Opens a file connection to construct the compilation script
file open comp using `"`scriptname'`extension'"', w replace
// Writes the appropriate OS header for a terminal script
file write comp "`header'" _n
// Writes the command to move into the directory where the executable is located
file write comp "`dirmove'" _n
// Calls pdfLaTeX to do the first pass
file write comp `"`bin' "`filenm'.tex""' _n
// Calls pdfLaTeX to do the second pass; this should finalize hyperrefs to
// individual graphs and TOC references as well as doing the initial insert
// and build of the TOC
file write comp `"`bin' "`filenm'.tex""' _n
// Calls pdfLaTeX to do the last pass; this should finalize the TOC/TOF and
// any other references like that
file write comp `"`bin' "`filenm'.tex""' _n
// Loop over ancillary file extensions
foreach v in aux lof log lot out toc {
// If Windows these file name references need to have a Windows path
// delimiter
if `"`c(os)'"' == "Windows" loc filenm `: subinstr loc filenm "/" "\", all'
// Delete ancillary files
file write comp `"`remove' "`filenm'.`v'""' _n
} // End Loop over ancillary file extensions
// Adds empty line
file write comp "" _n
// Adds empty line
file write comp "" _n
// Closes the open file connection
file close comp
// Need to make the file executable on *nix systems
`scriptexec'
// Return shell command to execute compilation script on OSX
if `"`c(os)'"' == "MacOSX" ret loc comp ! open -a Terminal.app `scriptname'`extension'
// For other OS
else ret loc comp ! `scriptname'`extension'
// End of subroutine definition
end
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jerryyang66/eda.git
git@gitee.com:jerryyang66/eda.git
jerryyang66
eda
eda
master

搜索帮助