Skip to content

Instantly share code, notes, and snippets.

@oscarperpinan
Created March 10, 2014 13:13
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/9464733 to your computer and use it in GitHub Desktop.
Save oscarperpinan/9464733 to your computer and use it in GitHub Desktop.
LaTeX file exported from orgChapter.org
\section{Code blocks}
\label{sec-1}
\label{sec:sectionA}
Code is enclosed within \texttt{\#+begin\_src/\#+end\_src}
\href{http://orgmode.org/manual/Structure-of-code-blocks.html}{blocks}.
\lstset{language=R,numbers=none}
\begin{lstlisting}
x <- 1:10
y <- 1:10
\end{lstlisting}
These blocks are \href{http://orgmode.org/manual/Extracting-source-code.html}{extracted creating a source code file} (\emph{tangling})
with \texttt{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 \texttt{C-c '= again to exit. If you need to evaluate it use
=C-c C-c}.
\subsection{Header arguments}
\label{sec-1-1}
Using the \href{http://orgmode.org/manual/Specific-header-arguments.html#Specific-header-arguments}{header argument} \texttt{:exports none} the next code chunk is \textbf{not}
included in the exported file (\LaTeX{} or HTML) but is included in the
tangled file (\texttt{R}). This option is useful to add configuration
code that you don't to show in the book.
Use \texttt{:tangle no} if you need to exclude a code chunk from the tangled
file.
\section{References}
\label{sec-2}
Use \texttt{C-c C-l} or \texttt{[[]]} to insert a link or a reference: Section
\ref{sec:sectionA}.
\section{Figures}
\label{sec-3}
Figure \ref{fig:dummyGraphic} is exported to a PDF file using the header arguments
\begin{itemize}
\item \texttt{:results output graphics}. The \href{http://orgmode.org/manual/results.html#results}{results header argument} writes the
graphics output to the file specified in the \href{http://orgmode.org/manual/file.html#file}{\texttt{:file} header
argument}. You need this specification when using \texttt{lattice} and
\texttt{ggplot2} graphics.
\item \href{http://orgmode.org/manual/exports.html#exports}{\texttt{:exports both}}. Both the code and results are included in the \LaTeX{}
exported file.
\end{itemize}
\lstset{language=R,numbers=none}
\begin{lstlisting}
xyplot(x ~ y)
\end{lstlisting}
\includegraphics[width=.9\linewidth]{myFig.pdf}
\subsection{\LaTeX{} attributes}
\label{sec-3-1}
The next lines insert the PDF file with \texttt{includegraphics} inside a
float figure in the \LaTeX{} file. Use \texttt{\#+CAPTION} to define the caption
and \#+ATTR\_LATEX\# to define the \texttt{includegraphics} arguments.
\begin{figure}[htb]
\centering
\includegraphics[height=0.45\textheight]{myFig.pdf}
\caption{\label{fig:dummyGraphic}A dummy graphic}
\end{figure}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment