问题
I have a sublime text build system for running latex. I am using a shell script (with no arguments) to delete the various extensions that are generated by latex. The problem is that sublime-text thinks filename.tex is the argument to the script.
So I tried the following script:
{
// General settings
"target": "make_pdf",
"selector": "text.tex.latex",
"cmd": ["latexmk", "-e","\\$dvipdf = 'dvipdfmx %O -o %D %S'", "-e", "\\$latex = 'latex %O -interaction=nonstopmode -synctex=1 %S'","-f", "-pdfdvi"],
"variants":
[
{ "cmd":["my_script.sh"],
"name": "clean"
}
]
}
Here I used ls in place of the script to illustrate. When I run the build-file, it tries to run
my_script.sh filename.tex
instead of just my_script.sh. What can I do to run just that from the build file ?
回答1:
I have been there and done that . . . there and back again . . . and visited again and again . . .
The solution is to use a custom plugin (not necessarily relying upon a .sublime-build, but that is possible too) so that you can refer to the *.tex file that is open. I have some solutions you are probably unaware of, one of which is my own, and one where I modify the popular plugin LaTexTools.
latexmk cleans with a big -C (everything) or a little -c (some things that are pre-defined, and additional things that can be user-defined) -- so there is no need to use a separate custom cleaner script.
https://github.com/lawlist/LaTexTools-Unofficial-Modification
https://github.com/lawlist/ST2-plugin-latexmk-save-build-clean
FYI: I recommend putting latex (or something like that) in your subject line of the question -- I almost missed your question . . . and just happened to see the short summary and realized I knew something about this issue.
SAMPLE -- for MultiTaskBuild plugin located here: https://github.com/bizoo/MultiTaskBuild
{
"cmd": {
"latexmk -pvc . . .": {
"cmd": ["latexmk", "-r", "/Users/HOME/.latexmkrc", "$file"]
},
"latexmk -pv . . .": {
"cmd": ["latexmk",
"-e", "\\$pdflatex = 'pdflatex -enable-write18 %O -interaction=nonstopmode -synctex=1 %S'",
"-recorder-", "-pvc-", "-f", "-pdf", "-pv", "$file"]
},
"latexmk -c": {
"cmd": ["latexmk", "-c", "$file"]
},
"latexmk -C": {
"cmd": ["latexmk", "-C", "$file"]
}
},
"path": "$PATH:/usr/texbin:/usr/local/bin",
"file_regex": "^(...*?):([0-9]+): ([0-9]*)([^\\.]+)",
"selector": "text.tex.latex",
"default_task": "latexmk -pv . . .",
"target": "multi_task_exec"
}
来源:https://stackoverflow.com/questions/16114576/run-shell-script-bash-commands-in-sublime-text-latex-build-without-any-file-argu