This extension gives support for Pweave files, namely formatting and building.
For the moment, this extension only supports LaTeX Pweave files using noweb syntax.
Example
\documentclass{article}
\begin{document}
This functions calculates the gcd of two integers.
<<>>=
def gcd(a, b):
while b!=0:
a, b = b, a % b
return a
@
\end{document}
Formatting is achieved with Alt+Shift+f. It uses autopep8
for python formatting and latexindent
for LaTeX formatting.
Building is achieved with Ctrl+Alt+b. It generates a LaTeX file. By default, Python code is rendered with verbatim
environments. This behaviour can be changed by modifying the pweaveOutputFormat
variable in the extension settings. Accepted values are tex
, texminted
and texpygments
(cf. Output Formats in Pweave documentation).
One can also changes the defaut behaviour by adding a magic comment in the Pweave LaTeX file.
%!TeX pweaveOutputFormat=tex
%!TeX pweaveOutputFormat=texminted
%!TeX pweaveOutputFormat=texpygments
Ctrl+Alt+v displays the generated LaTeX file in a pane beside the active editor.
autopep8
This can be installed via pip
.
pip install autopep8
latexindent
This executable is usually included in common LaTeX distributions butcan also be downloaded from https://ctan.org/pkg/latexindent.
pweave
This can be installed via pip
.
pip install pweave
This extension contributes the following settings:
vscode-pweave.autopep8Path
: path of theautopep8
executable. Defaults toautopep8
.vscode-pweave.latexindentPath
: path of thelatexindent
executable. Defaults tolatexindent
.vscode-pweave.pweavePath
: path of thepweave
executable. Defaults topweave
.vscode-pweave.pweaveOutputFormat
: Pweave output format :'tex'
or'texminted'
or'texpygments'
.
This extension does not yet provide autocompletion. This is on the todo list.