Last active
June 2, 2021 11:44
-
-
Save GillesC/f176f58d104567144d66c1eb1a9a2bbc to your computer and use it in GitHub Desktop.
LaTex in VSCode + Helper Scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add to keybindings.json: File > Preferences > Keyboard Shortcuts > change to JSON view | |
[ | |
{ | |
"key":"ctrl+b", | |
"command":"editor.action.insertSnippet", | |
"args":{ | |
"name":"Insert bold text" | |
} | |
}, | |
{ | |
"key":"ctrl+i", | |
"command":"editor.action.insertSnippet", | |
"args":{ | |
"name":"Insert italic text" | |
} | |
}, | |
{ | |
"key":"ctrl+shift+i", | |
"command":"editor.action.insertSnippet", | |
"args":{ | |
"name":"itemize" | |
} | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Group of snippets, settings and scripts to help in using LaTex for papers, thesis dissertations,... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Script to remove double acronyms from a tex file. | |
""" | |
import sys | |
import re | |
def main(): | |
REGEX = r"^\\newacronym(\[(?P<plural>.*)\])?\{(?P<key>.*)\}\{(?P<abbr>.*)\}\{(?P<expand>.*)\}" | |
abbr = {} | |
with open("abbr.tex", 'r') as f: | |
for line in f: | |
m = re.search(REGEX, line) | |
if m is not None: | |
key = m.group('key') | |
print(key) | |
if key in abbr: | |
if abbr[key] == line: | |
print("same entry so ignored the double") | |
else: | |
print("Duplicate found, which to keep?") | |
choice = int(input(f"1: {abbr[key]} or 2: {line}")) | |
if choice == 2: | |
abbr[key] = line | |
else: | |
abbr[key] = line | |
with open("abbr-cleaned.tex", 'w') as f: | |
for _, v in abbr.items(): | |
f.write(v) | |
if __name__ == "__main__": | |
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// VSCode settings with custom recipes for building, e.g., the KU Leuven PhD dissertation | |
// add the body to the user settings: ctrl+shift+p > user settings > open JSON view | |
{ | |
"python.formatting.autopep8Args":[ | |
"--max-line-length=200" | |
], | |
"latex-workshop.chktex.enabled":true, | |
"latex-workshop.intellisense.package.enabled":true, | |
"latex-workshop.latex.magic.args":[ | |
"--shell-escape", | |
"-synctex=1", | |
"-interaction=nonstopmode", | |
"-file-line-error", | |
"%DOC%" | |
], | |
"latex-workshop.latex.recipes":[ | |
{ | |
"name":"lualatex", | |
"tools":[ | |
"lualatex" | |
] | |
}, | |
{ | |
"name":"PhD", | |
"tools":[ | |
"pdflatex", | |
"pdflatex", | |
"biber", | |
"makeIndex1", | |
"makeIndex2", | |
"pdflatex", | |
"pdflatex" | |
] | |
}, | |
{ | |
"name": "PhDlua", | |
"tools": [ | |
"lualatex", | |
"lualatex", | |
"biber", | |
"makeIndex1", | |
"makeIndex2", | |
"lualatex", | |
"lualatex" | |
] | |
}, | |
{ | |
"name":"lualatex ➞ bibtex ➞ lualatex × 2", | |
"tools":[ | |
"lualatex", | |
"bibtex", | |
"lualatex", | |
"lualatex" | |
] | |
}, | |
{ | |
"name":"pdflatex ➞ gloss ➞ pdflatex x 2", | |
"tools":[ | |
"pdflatex", | |
"makeglossaries", | |
"pdflatex", | |
"pdflatex" | |
] | |
}, | |
{ | |
"name":"latexmk 🔃", | |
"tools":[ | |
"latexmk" | |
] | |
} | |
], | |
"latex-workshop.latex.tools":[ | |
{ | |
"name":"latexmk", | |
"command":"latexmk", | |
"args":[ | |
"-xelatex", | |
"-shell-escape", | |
"-synctex=1", | |
"-interaction=nonstopmode", | |
"-file-line-error", | |
"-pdf", | |
"%DOC%" | |
] | |
}, | |
{ | |
"name":"lualatex", | |
"command":"lualatex", | |
"args":[ | |
"-shell-escape", | |
"-synctex=1", | |
"-interaction=nonstopmode", | |
"-file-line-error", | |
"%DOC%" | |
] | |
}, | |
{ | |
"name":"biber", | |
"command":"biber", | |
"args":[ | |
"%DOCFILE%" | |
] | |
}, | |
{ | |
"name":"makeglossaries", | |
"command":"makeglossaries", | |
"args":[ | |
"%DOCFILE%" | |
] | |
}, | |
{ | |
"name":"pdflatex", | |
"command":"pdflatex", | |
"args":[ | |
"-shell-escape", | |
"-synctex=1", | |
"-interaction=nonstopmode", | |
"-file-line-error", | |
"%DOC%" | |
] | |
}, | |
{ | |
"name":"bibtex", | |
"command":"bibtex", | |
"args":[ | |
"%DOCFILE%" | |
] | |
}, | |
{ | |
"name":"makeIndex1", | |
"command":"makeindex", | |
"args":[ | |
"%DOCFILE%.glo", | |
"-s", | |
"%DOCFILE%.ist", | |
"-t", | |
"%DOCFILE%.glg", | |
"-o", | |
"%DOCFILE%.gls" | |
] | |
}, | |
{ | |
"name":"makeIndex2", | |
"command":"makeindex", | |
"args":[ | |
"%DOCFILE%.nlo", | |
"-s", | |
"nomencl.ist", | |
"-o", | |
"%DOCFILE%.nls" | |
] | |
} | |
], | |
"latex-workshop.latex.autoBuild.run":"never" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add snippet File > Preferences > User Snippets > latex.json | |
{ | |
"Insert bold text":{ | |
"prefix":"bold", | |
"body":"\\textbf{${1:${TM_SELECTED_TEXT}}}$0", | |
"description":"Insert bold text" | |
}, | |
"Insert italic text":{ | |
"prefix":"italic", | |
"body":"\\textit{${1:${TM_SELECTED_TEXT}}}$0", | |
"description":"Insert italic text" | |
}, | |
"itemize":{ | |
"prefix":"itemize", | |
"body":[ | |
"\\begin{itemize}", | |
" \\item", | |
"\\end{itemize}" | |
], | |
"description":"itemize" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment