Skip to content

Instantly share code, notes, and snippets.

@oscarperpinan
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oscarperpinan/9463438 to your computer and use it in GitHub Desktop.
Save oscarperpinan/9463438 to your computer and use it in GitHub Desktop.
orgmode example for writing a chapter

Code blocks

<sec:sectionA>

Code is enclosed within #+begin_src/#+end_src blocks.

x <- 1:10
y <- 1:10

These blocks are extracted creating a source code file (tangling) with C-c C-v t. Without header arguments the code chunk is exported and tangled as is. Use C-c’ to edit the current code block. This brings up a language major-mode edit buffer containing the body of the code block. Use C-c’ again to exit. If you need to evaluate it use C-c C-c.

Header arguments

Using the header argument :exports none the next code chunk is not included in the exported file (LaTeX or HTML) but is included in the tangled file (R code). This option is useful to add configuration code that you don’t want to show in the book.

Use :tangle no if you need to exclude a code chunk from the tangled file.

References

Use C-c C-l or [[]] to insert a link or a reference: Section sec:sectionA.

Figures

Figure fig:dummyGraphic is exported to a PDF file using the header arguments

xyplot(x ~ y)

LaTeX attributes

The next lines insert the PDF file with includegraphics inside a float figure in the LaTeX file. Use #+CAPTION to define the caption and #+ATTR_LATEX# to define the includegraphics arguments.

myFig.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment