Pweave icon indicating copy to clipboard operation
Pweave copied to clipboard

Ability To Break Document into Smaller Children like knitr

Open LarsaSolidor opened this issue 7 years ago • 4 comments

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

  • Assignment_1.Rnw
  • Assignment_1-1.Rnw
  • Assignment_1-2.Rnw
  • Assignment_1-3.Rnw

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?

LarsaSolidor avatar Oct 11 '18 14:10 LarsaSolidor

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.

slackline avatar Feb 08 '19 09:02 slackline

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

mpastell avatar Feb 08 '19 12:02 mpastell

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

slackline avatar Feb 08 '19 14:02 slackline

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.

slackline avatar Mar 11 '19 12:03 slackline