mirror of https://github.com/mpastell/Weave.jl
6 lines
10 KiB
HTML
6 lines
10 KiB
HTML
<!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 rel="canonical" href="http://weavejl.mpastell.com/stable/chunk_options/"/><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/5.11.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../assets/documenter.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-dark.css" data-theme-name="documenter-dark"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><div class="docs-package-name"><span class="docs-autofit">Weave.jl</span></div><form class="docs-search" action="../search/"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li><a class="tocitem" href="../">Weave.jl - Scientific Reports Using Julia</a></li><li><a class="tocitem" href="../getting_started/">Getting started</a></li><li><a class="tocitem" href="../usage/">Using Weave</a></li><li><a class="tocitem" href="../publish/">Publishing to HTML and PDF</a></li><li class="is-active"><a class="tocitem" href>Chunk options</a><ul class="internal"><li><a class="tocitem" href="#Options-for-code-1"><span>Options for code</span></a></li><li><a class="tocitem" href="#Options-for-figures-1"><span>Options for figures</span></a></li><li><a class="tocitem" href="#Set-default-chunk-options-1"><span>Set default chunk options</span></a></li></ul></li><li><a class="tocitem" href="../notebooks/">Working with Jupyter notebooks</a></li><li><a class="tocitem" href="../function_index/">Function index</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li class="is-active"><a href>Chunk options</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Chunk options</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://github.com/JunoLab/Weave.jl/blob/master/doc/src/chunk_options.md" title="Edit on GitHub"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch">Edit on GitHub</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="Chunk-options-1"><a class="docs-heading-anchor" href="#Chunk-options-1">Chunk options</a><a class="docs-heading-anchor-permalink" href="#Chunk-options-1" title="Permalink"></a></h1><p>I've mostly followed <a href="http://yihui.name/knitr/options">Knitr</a>'s naming for chunk options, but not all options are implemented.</p><p>Options are separated using ";" and need to be valid Julia expressions. Example: markdown code chunk that saves and displays a 12 cm wide image and hides the source code:</p><p><code>julia; out_width="12cm"; echo=false</code></p><p>Weave currently supports the following chunk options with the following defaults:</p><h2 id="Options-for-code-1"><a class="docs-heading-anchor" href="#Options-for-code-1">Options for code</a><a class="docs-heading-anchor-permalink" href="#Options-for-code-1" title="Permalink"></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 = "markup"</code>: The output format of the printed results. <code>"markup"</code> for literal block, <code>"hidden"</code> for hidden results, or anything else for raw output (I tend to use <code>"tex"</code> for Latex and <code>"rst"</code> 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 <code>false</code> the chunk won’t be executed.</li><li><code>term = false</code>: If <code>true</code> the output emulates a REPL session. Otherwise only stdout and figures will be included in output.</li><li><code>label = nothing</code>: Chunk label, will be used for figure labels in Latex as <code>fig:label</code>.</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, depending 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 <code>false</code> to exclude chunk from tangled code.</li></ul><h2 id="Options-for-figures-1"><a class="docs-heading-anchor" href="#Options-for-figures-1">Options for figures</a><a class="docs-heading-anchor-permalink" href="#Options-for-figures-1" title="Permalink"></a></h2><ul><li><code>fig_width = 6</code>: Figure width passed to plotting library.</li><li><code>fig_height = 4</code>: Figure height passed to plotting library.</li><li><code>out_width</code>: Width of saved figure in output markup e.g. <code>"50%"</code>, <code>"12cm"</code>, <code>0.5\linewidth</code></li><li><code>out_height</code>: Height of saved figure in output markup</li><li><code>dpi = 96</code>: 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 = "!h"</code>: Figure position in Latex, e.g.: <code>"ht"</code>.</li><li><code>fig_env = "figure"</code>: Figure environment in Latex.</li></ul><h2 id="Set-default-chunk-options-1"><a class="docs-heading-anchor" href="#Set-default-chunk-options-1">Set default chunk options</a><a class="docs-heading-anchor-permalink" href="#Set-default-chunk-options-1" title="Permalink"></a></h2><p>You can set the default chunk options (and <code>weave</code> arguments) for a document using the YAML header <code>options</code> field. E.g. to set the default <code>out_width</code> of all figures you can use:</p><pre><code class="language-yaml">---
|
||
options:
|
||
out_width : 50%
|
||
---</code></pre><p>You can also set or change the default chunk options for a document either before weave using the <code>set_chunk_defaults</code> function.</p><article class="docstring"><header><a class="docstring-binding" id="Weave.set_chunk_defaults" href="#Weave.set_chunk_defaults"><code>Weave.set_chunk_defaults</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">set_chunk_defaults(opts::Dict{Symbol, Any})</code></pre><p>Set default options for code chunks, use <a href="#Weave.get_chunk_defaults"><code>get_chunk_defaults</code></a> to see the current values.</p><p>E.g.: set default <code>dpi</code> to <code>200</code> and <code>fig_width</code> to <code>8</code></p><pre><code class="language-julia">julia> set_chunk_defaults(Dict{Symbol, Any}(:dpi => 200, fig_width => 8))</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JunoLab/Weave.jl/blob/ed5b4897d024838ec745d991980dc5fea46e6b78/src/config.jl#L42-L52">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Weave.get_chunk_defaults" href="#Weave.get_chunk_defaults"><code>Weave.get_chunk_defaults</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">get_chunk_defaults()</code></pre><p>Get default options used for code chunks.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JunoLab/Weave.jl/blob/ed5b4897d024838ec745d991980dc5fea46e6b78/src/config.jl#L58-L62">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="Weave.restore_chunk_defaults" href="#Weave.restore_chunk_defaults"><code>Weave.restore_chunk_defaults</code></a> — <span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia">restore_chunk_defaults()</code></pre><p>Restore Weave.jl default chunk options.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JunoLab/Weave.jl/blob/ed5b4897d024838ec745d991980dc5fea46e6b78/src/config.jl#L67-L71">source</a></section></article></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../publish/">« Publishing to HTML and PDF</a><a class="docs-footer-nextpage" href="../notebooks/">Working with Jupyter notebooks »</a></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> on <span class="colophon-date" title="Friday 8 May 2020 18:21">Friday 8 May 2020</span>. Using Julia version 1.4.1.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
|