Weave.jl/dev/chunk_options/index.html

15 lines
6.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Chunk options · Weave.jl</title><link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/4.2.0/normalize.min.css" rel="stylesheet" type="text/css"/><link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Mono" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.min.js" data-main="../assets/documenter.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link href="../assets/documenter.css" rel="stylesheet" type="text/css"/></head><body><nav class="toc"><h1>Weave.jl</h1><select id="version-selector" onChange="window.location.href=this.value" style="visibility: hidden"></select><form class="search" id="search-form" action="../search/"><input id="search-query" name="q" type="text" placeholder="Search docs"/></form><ul><li><a class="toctext" href="../">Weave.jl - Scientific Reports Using Julia</a></li><li><a class="toctext" href="../getting_started/">Getting started</a></li><li><a class="toctext" href="../usage/">Using Weave</a></li><li><a class="toctext" href="../publish/">Publishing to html and pdf</a></li><li class="current"><a class="toctext" href>Chunk options</a><ul class="internal"><li><a class="toctext" href="#Options-for-code-1">Options for code</a></li><li><a class="toctext" href="#Options-for-figures-1">Options for figures</a></li><li><a class="toctext" href="#Set-default-chunk-options-1">Set default chunk options</a></li></ul></li><li><a class="toctext" href="../notebooks/">Working with Jupyter notebooks</a></li><li><a class="toctext" href="../function_index/">Function index</a></li></ul></nav><article id="docs"><header><nav><ul><li><a href>Chunk options</a></li></ul><a class="edit-page" href="https://github.com/mpastell/Weave.jl/blob/master/doc/src/chunk_options.md"><span class="fa"></span> Edit on GitHub</a></nav><hr/><div id="topbar"><span>Chunk options</span><a class="fa fa-bars" href="#"></a></div></header><h1><a class="nav-anchor" id="Chunk-options-1" href="#Chunk-options-1">Chunk options</a></h1><p>I&#39;ve mostly followed <a href="http://yihui.name/knitr/options">Knitr</a>&#39;s naming for chunk options, but not all options are implemented.</p><p>Options are separated using &quot;;&quot; and need to be valid Julia expressions. Example: A code chunk that saves and displays a 12 cm wide image and hides the source code:</p><pre><code class="language-julia">&lt;&lt;out_width=&quot;12cm&quot;; echo=false &gt;&gt;=
using Gadfly
x = linspace(0, 2π, 200)
plot(x=x, y = sin(x), Geom.line)
@</code></pre><p>Weave currently supports the following chunk options with the following defaults:</p><h2><a class="nav-anchor" id="Options-for-code-1" href="#Options-for-code-1">Options for code</a></h2><ul><li><code>echo = true</code>. Echo the code in the output document. If <code>false</code> the source code will be hidden.</li><li><code>results = &quot;markup&quot;</code>. The output format of the printed results. &quot;markup&quot; for literal block, &quot;hidden&quot; for hidden results or anything else for raw output (I tend to use tex for Latex and rst for rest. Raw output is useful if you want to e.g. create tables from code chunks.</li><li><code>eval = true</code>. Evaluate the code chunk. If false the chunk wont be executed.</li><li><code>term=false</code>. If true the output emulates a REPL session. Otherwise only stdout and figures will be included in output.</li><li><code>label</code>. Chunk label, will be used for figure labels in Latex as fig:label</li><li><code>wrap = true</code>. Wrap long lines from output.</li><li><code>line_width = 75</code>. Line width for wrapped lines.</li><li><code>cache = false</code>. Cache results, depends on <code>cache</code> parameter on <code>weave</code> function.</li><li><code>hold = false</code>. Hold all results until the end of the chunk.</li><li><code>tangle = true</code>. Set tangle to false to exclude chunk from tangled code.</li></ul><h2><a class="nav-anchor" id="Options-for-figures-1" href="#Options-for-figures-1">Options for figures</a></h2><ul><li><code>fig_width</code>. Figure width passed to plotting library e.g. <code>800</code></li><li><code>fig_height</code> Figure height passed to plotting library</li><li><code>out_width</code>. Width of saved figure in output markup e.g. &quot;50%&quot;, &quot;12cm&quot;, <code>\\0.5linewidth</code></li><li><code>out_height</code>. Height of saved figure in output markup</li><li><code>dpi</code>=96. Resolution of saved figures.</li><li><code>fig_cap</code>. Figure caption.</li><li><code>label</code>. Chunk label, will be used for figure labels in Latex as fig:label</li><li><code>fig_ext</code>. File extension (format) of saved figures.</li><li><code>fig_pos=&quot;htpb&quot;</code>. Figure position in Latex. </li><li><code>fig_env=&quot;figure&quot;</code>. Figure environment in Latex.</li></ul><h2><a class="nav-anchor" id="Set-default-chunk-options-1" href="#Set-default-chunk-options-1">Set default chunk options</a></h2><p>You can set or change the default chunk options for a document either before running weave or inside the weaved document. You can e.g. use a hidden chunk in the beginning of the source document to set the options:</p><pre><code class="language-julia">&lt;&lt;echo = false&gt;&gt;=
import Weave
Weave.set_chunk_defaults(Dict{Symbol, Any}(
:out_width =&gt; &quot;\\0.5linewidth&quot;,
:results =&gt; &quot;tex&quot;
))
@</code></pre><pre><code class="language-none">set_chunk_defaults(opts)
get_chunk_defaults()
restore_chunk_defaults()</code></pre><footer><hr/><a class="previous" href="../publish/"><span class="direction">Previous</span><span class="title">Publishing to html and pdf</span></a><a class="next" href="../notebooks/"><span class="direction">Next</span><span class="title">Working with Jupyter notebooks</span></a></footer></article></body></html>