mpastell / Pweave

Pweave is a scientific report generator and a literate programming tool for Python. It can capture the results and plots from data analysis and works well with numpy, scipy and matplotlib.
http://mpastell.com/pweave
Other
435 stars 64 forks source link

Ability To Break Document into Smaller Children like knitr #130

Open LarsaSolidor opened 6 years ago

LarsaSolidor commented 6 years ago

In knitr, I can use the below pieces of code to break a document into seperate files:

Assignment_1.Rnw

<<child-demo, child='Assignment_1-1.Rnw'>>=
@

<<child-demo, child='Assignment_1-2.Rnw'>>=
@

<<child-demo, child='Assignment_1-3.Rnw'>>=
@

In the directory I have these files

When I call knitr on Assignment_1.Rnw it combines all four files into one .tex document before passing it through latex to get the PDF.

Would it be possible to add similar functionality to Pweave?

slackline commented 5 years ago

I'd be interested to know how to do this too. Initially I thought using \include{} or \input{} as is common in modular documents might work, but because Pweave is processing the document and its not being compiled from tex to PDF the child documents are .texw they're not pulled in.

mpastell commented 5 years ago

You can use the source chunk option: http://mpastell.com/pweave/chunks.html#envvar-source

slackline commented 5 years ago

Thanks for the pointer I'll give that a go.

slackline commented 5 years ago

Found time to give this a go and can't seem to specify child documents that are .texw.

pweave_example.texw

\documentclass[hidelinks, 11pt]{article}
\geometry{a4paper,left=25mm, right=25mm, top=20mm, bottom=20mm}
\begin{document}
Lets try including a child document.
<<intro, eval=True, echo=False, results='tex', source='pweave_intro.texw'>>=
@
\end{document}

pweave_intro.texw \clearpage This is a child document.

After weaving this with...

pweave pweave_example.texw

...the resulting .tex is...

\documentclass[hidelinks, 11pt]{article}
\geometry{a4paper,left=25mm, right=25mm, top=20mm, bottom=20mm}
\begin{document}
Lets try including a child document.

\textcolor{ansi-cyan}{  File }\textcolor{ansi-green}{"<ipython-input-1-7b7bb7cedd73>"}\textcolor{ansi-cyan}{, line }\textcolor{ansi-green}{1}
\textcolor{ansi-red}{    \clearpage}
              ^
\textcolor{ansi-red}{SyntaxError}\textcolor{ansi-red}{:} unexpected character after line continuation character

\end{document}

I'm still confused how to include child .texw and have them parsed correctly.