mirror of https://github.com/mpastell/Weave.jl
12 lines
12 KiB
HTML
12 lines
12 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="#Syntax-1"><span>Syntax</span></a></li><li><a class="tocitem" href="#Weave-Chunk-Options-1"><span>Weave Chunk Options</span></a></li><li><a class="tocitem" href="#Default-Chunk-Options-1"><span>Default Chunk Options</span></a></li></ul></li><li><a class="tocitem" href="../header/">Header Configuration</a></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>You can use chunk options to configure how each chunk is evaluated, rendered, etc. Most of the ideas came from <a href="http://yihui.name/knitr/options">chunk options in RMarkdown</a>.</p><h2 id="Syntax-1"><a class="docs-heading-anchor" href="#Syntax-1">Syntax</a><a class="docs-heading-anchor-permalink" href="#Syntax-1" title="Permalink"></a></h2><p>Chunk options come after <a href="../usage/#code-chunks-1">code chunk</a> header. There are two (slightly) different syntax to write them:</p><ul><li>(Julia's toplevel expression) options are separated by semicolon (<code>;</code>)</li><li>(RMarkdown style) options are separated by comma (<code>,</code>)</li></ul><p>Let's take a look at examples. All the following code chunk header are valid, and so configured to hide the source code from generated output (<code>echo = false</code>) and displays figures with 12cm width (<code>out_width = "12cm"</code>):</p><pre><code class="language-md"> ```julia; echo = false; out_width = "12cm"
|
||
|
||
```{julia; echo = false; out_width = "12cm"}
|
||
|
||
```julia, echo = false, out_width = "12cm"
|
||
|
||
```{julia, echo = false, out_width = "12cm"}</code></pre><h2 id="Weave-Chunk-Options-1"><a class="docs-heading-anchor" href="#Weave-Chunk-Options-1">Weave Chunk Options</a><a class="docs-heading-anchor-permalink" href="#Weave-Chunk-Options-1" title="Permalink"></a></h2><p>Weave currently supports the following chunk options: we've mostly followed <a href="http://yihui.name/knitr/options">RMarkdown's namings</a>, but not all options are implemented.</p><h3 id="Evaluation-1"><a class="docs-heading-anchor" href="#Evaluation-1">Evaluation</a><a class="docs-heading-anchor-permalink" href="#Evaluation-1" title="Permalink"></a></h3><ul><li><code>eval = true</code>: Evaluate the code chunk. If <code>false</code> the chunk won’t be executed.</li><li><code>cache = false</code>: Cache results, depending on <code>cache</code> parameter on <a href="../usage/#Weave.weave"><code>weave</code></a> function.</li><li><code>tangle = true</code>: Set tangle to <code>false</code> to exclude chunk from tangled code.</li></ul><h3 id="Rendering-1"><a class="docs-heading-anchor" href="#Rendering-1">Rendering</a><a class="docs-heading-anchor-permalink" href="#Rendering-1" title="Permalink"></a></h3><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>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>wrap = true</code>: Wrap long lines from output.</li><li><code>line_width = 75</code>: Line width for wrapped lines.</li><li><code>hold = false</code>: Hold all results until the end of the chunk.</li></ul><h3 id="Figures-1"><a class="docs-heading-anchor" href="#Figures-1">Figures</a><a class="docs-heading-anchor-permalink" href="#Figures-1" title="Permalink"></a></h3><ul><li><code>label = nothing</code>: Chunk label, will be used for figure labels in Latex as <code>fig:label</code>.</li><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>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="Default-Chunk-Options-1"><a class="docs-heading-anchor" href="#Default-Chunk-Options-1">Default Chunk Options</a><a class="docs-heading-anchor-permalink" href="#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 <code>weave_options</code> key in YAML <a href="../header/#Header-Configuration-1">Header Configuration</a>. E.g. to set the default <code>out_width</code> of all figures you can use:</p><pre><code class="language-yaml">---
|
||
weave_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(:dpi => 200, :fig_width => 8))</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JunoLab/Weave.jl/blob/3e6cda8950ad63de4e5efb24993cc4691fe05e38/src/config.jl#L39-L49">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/3e6cda8950ad63de4e5efb24993cc4691fe05e38/src/config.jl#L52-L56">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/3e6cda8950ad63de4e5efb24993cc4691fe05e38/src/config.jl#L59-L63">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="../header/">Header Configuration »</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="Tuesday 2 June 2020 11:12">Tuesday 2 June 2020</span>. Using Julia version 1.4.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
|