Index of /latex/
<html>
<body>
Paul Johnson <pauljohn@ku.edu>
<P>
<H1>LaTeX, LyX, and Sweave Notes</H1>
<P>
Quite a few people come by at random and say "how do I do LaTeX". It
became common enough that I decided I better collect up my
material. This is my survey page.
<P>
<H2>Where to get started on LaTeX?</H2>
<P>
1. Please understand. LaTeX is a format in which text files can be
written and then processed into other output formats, like Adobe "pdf"
or hypertext markup language. Many people edit LaTeX documents
"directly" with editors like Emacs, TexMaker, TexShop, Kate, WinEdt,
and many others. I can/do use that approach with some projects, but I
find I generally get more done with LyX, which is a "point and click"
editor not entirely different from modern word processors. LyX has
the ability to output documents to LaTeX format, and then they are
processed into PDF or other exchangeable formats. LyX can make the
compilation by LaTeX tools and the viewing of PDF into a seamless
process. The user is barely aware of the fact that LaTeX is doing
the work in the background.
<P>
2. Please understand. LaTeX also is a suite of programs that translate
documents in the LaTeX format into outputs. A bundle of programs and
style files is called a LaTeX distribution. On Unix/Linux systems,
the most common LaTeX distribution was tetex, but now it has been
superceded by TeXLive. On MS Windows systems, it appears that the
MikTeX distribution of LaTeX programs is the most widely used.
<P>
Aside from that, the devil is in the details. I suggest that people who want
to get started with LaTeX should
<ol>
<li>Install a LaTeX distribution</li>
<li>Make sure that distribution is sufficient by "compiling" some sample LaTeX
documents.</li>
<li>Find example LaTeX documents written by others that "work" and then revise
them</li>
<li>While editing, re-compile every 10 minutes or so, because it is very difficult
to find some novice mistakes when they are buried in a lot of text</li>
</ol>
I'm working on a book chapter. Look in <a href="doc">doc</a> folder for "StuffWorthKnowing-latex.pdf"
<P>
My other material I write about LaTeX and Lyx is collected
here <a href="http://pj.freefaculty.org/guides/Computing-HOWTO/LatexAndLyx">http://pj.freefaculty.org/guides/Computing-HOWTO/LatexAndLyx"</a>.
I am trying to collect up all of the miscellaneous and sundry "howto"
sheets I've prepared under that heading. This is a work in progress.
As of October, 2014, that has
<ul>
<li><a href="../guides/Computing-HOWTO/LatexAndLyx/LyX-Beginner">
A pleasant exploration of a first-session of a new LyX user</a></li>
<li><a href="../guides/Computing-HOWTO/LatexAndLyx/LyX-article-template">Making a template for LyX articles</a></li>
<li><a href="http://pj.freefaculty.org/guides/Computing-HOWTO/LatexAndLyx/LaTeX-General-1/LaTeX-lecture-1.pdf">Overview of LaTeX (LaTeX-lecture-1.pdf)</a></li>
<li><a href="http://pj.freefaculty.org/guides/Computing-HOWTO/LatexAndLyx/LyX-sweave-tutorial">Sweave=embedding R code into LaTeX documents to produce Replicable Reports and Presentations</a></li>
<li><a href="http://pj.freefaculty.org/guides/Computing-HOWTO/LatexAndLyx/LyX-Features-1"> LyX Highlights </a></li>
<li><a href="http://pj.freefaculty.org/guides/Computing-HOWTO/LatexAndLyx/LyX-ParagraphTypes/lyx-paragraph-types.pdf">Lyx Paragraph Types</a></li>
<li><a href="
http://pj.freefaculty.org/guides/Computing-HOWTO/LatexAndLyx/LyX-Bibliography">Bibliography Usage with LateX and Lyx</a></li>
</ul>
<p>Each of those folders <b>should</b> have the LyX document, the PDF output, and the other files required to reproduce the PDF.</p>
<P>
I created the University of Kansas LaTeX style file and example documents. That has been accepted by the Graduate School for MA and PhD theses (Hooray!).
<P>
Look Under<a href="http://pj.freefaculty.org/guides/Computing-HOWTO/KU-thesis">
http://pj.freefaculty.org/guides/Computing-HOWTO/KU-thesis</a>. The file "KU-thesis-xxx.zip" is the whole set of files, but if you just want to read about how to do this, I suggest you read the file <a href="http://pj.freefaculty.org/guides/Computing-HOWTO/KU-thesis/thesis-ku.pdf">thesis-ku.pdf</a>
<P>
Now, supposing you agree that it is easier and more fun to work with LyX as the document interface, what to read? Many people I know started with
<P>
<a href="http://www.stat.rice.edu/~helpdesk/howto/lyxguide.html">A Simple Guide to Latex/Lyx"</a>
<P>
On this website, there is a list of tutorials for LyX in particular:
<P>
<a href="http://wiki.lyx.org/LyX.Tutorials">http://wiki.lyx.org/LyX.Tutorials</a>
<P>
In particular, The Essentials of LyX by Stephen Wolff and Liviu Andronic will be helpful (local copy in the doc folder).
<P>
For General LaTeX background reading, there are many helpful documents available. Of course,
the canonical source, is <i>The LaTeX Companion</i>, by Michel Gossens, Frank MIttelbach,
and Alexander Samarin (Addison-Wesley, 1994). That's getting a bit rusty by now,
there are quite a few nice guides you'll find.
<p> Recently I found Nicola Talbot's book <i>LaTeX for Complete Novices</i>.
<b>Very Excellent</b> I've saved
a copy in my doc directory here, I have version 1.4, but you can go to her
website to find the latest and greatest
<a href="http://www.dickimaw-books.com/latex/novices"> http://www.dickimaw-books.com/latex/novices</a>.
The Website says that is released under teh GNU documetation license, and you can even
get the (very complicated) source code that produces the document itself.
<P>
I remember also thinking that the free book in here is informative:
<a href="http://en.wikibooks.org/wiki/LaTeX"> Wikibooks LaTeX </a>.
<p>
In the end, though, there's no substitute for starting with a template document, adding
some content, and then compiling to see if it works.
<H2>Getting Started With Sweave</H2>
<P>
Suppose you can make LaTeX and LyX "work" on some practice documents.
What about Sweave?</p>
<P>
I started an Sweave tutorial that, for the moment, is in my R folder:
<P>
<a href="http://pj.freefaculty.org/R">http://pj.freefaculty.org/R</a>. Start with the first one, then the second one (Duh!).
<P>
Here is the basic workflow.
<P>
Step 1. Write a LaTeX document with R code embedded in code chunks, like so:
<pre>
<<chunk1>>=
x <- rnorm(100)
mean(x)
@
</pre>
The document will need to have some other special LaTeX boilerplate in
it, but that's no trouble.
<br>
Step 2. Save that LaTeX document in a file with a name like "example.Rnw". Note the Rnw suffix.
<br>
Step 3. Run the document through R, which converts the Rnw file into a LaTeX file.
<br>
Step 4. Process the document example.tex through whatever LaTeX document processing system one would ordinarily use.
<P>
This process requires that the R and LaTeX distributions must work together.
If the work is done inside some R development environment or editor,
such as Emacs
or RStudio or Eclipse or WinEdt or ..., then the editor has to interact with R and LaTeX effectively. The only thing I am very sure of is that the elementary text script editor provided with R for Windows is Not Sufficient.
<P>
I think that working with Sweave is considerably easier in a
Linux/Unix or a Mac environment. It is possible in MS Windows,
however, and while testing the tutorial, I did make it work with
an MS Windows user. As I recall, these were the challenges in
making his setup work. First, R did not install Sweave.sty in a
place where "TeXLive" could find it when processing documents.
I believe that if TeXLive is installed before R is installed,
that problem may be solved. But, in any case, a person who
chooses to use MS Windows also chooses to put up with a lot of
crap, and figuring how to add new style files in TeXLive is an
example. I think the Sweavel.sty file produces nicer results,
so we had to install that too. Second, as I recall, it was also
necessary to put R's executable in the system path. There were some wrinkles, but don't be afraid. It can be made to work on Windoze.
<P>
In Windows, perhaps the easiest way to get started is to install
the GUI R environment called RStudio. If we open a file with
suffix "*.Rnw" in RStudio, then RStudio tries to find the programs
that are needed to compile a document. I think RStudio is fundamentally
limited and only ultra-novices should mess about with it, but
it does have some user-friendly system administration conveniences
when you are battling with an MS Windows system.
<P>
Don't come and ask me questions until you have reviewed <b>THE CANONICAL SOURCE</b> on
Sweave, Friedrich Leisch's <it>Sweave User Manual</it>. The <it>Sweave User Manual</it> is
distributed with R itself, in the documentation of the package "utils".
<P>
<H3>Sweave Links </H3>
<ul>
<li>Sweave Intro U. Montana http://www.math.montana.edu/~jimrc/classes/Rseminar/SweaveIntro.html</li>
<li>Charles Geyer Sweave Demo: http://users.stat.umn.edu/~geyer/Sweave</li>
<li>Getting Genetics Done: Latex and Sweave for Reproducible Research. http://gettinggeneticsdone.blogspot.com/2010/05/using-r-latex-and-sweave-for.html</li>
</ul>
<H3>Sweave Docs I downloaded and earmarked</H3>
<P>
Other materials in my doc folder are collected from other
websites. Generally speaking, newer documents are more likely to be
relevant to the current programs, but not all of these are brand new.
I wish one of my graduate students would do some searches to see if
updated versions are available :)
<UL>
<li>Peter Filzmoser, "Latex and R via Sweave: An example document how to use Sweave" Local copy: http://pj.freefaculty.org/latex/doc/Filzmoser-SweaveExa.pdf
<LI>D.G. Rossiter, "Techincal Note: Literate Data Analysis". Local copy: http://pj.freefaculty.org/latex/doc/Rossiter-LiterateDataAnalysis-Sweave.pdf </LI>
<LI>Murat Yildizoglu, "LyX and Sweave under Windows XP 'Yes, we can!'" Local copy http://pj.freefaculty.org/latex/doc/MuratYildizoglu-lyx-sweave.pdf</LI>
<li>Ista Zahn, "Learning to Sweave in APA Style." http://pj.freefaculty.org/latex/doc/Zahn-SweaveAPAStyle.pdf</li>
<li>Virgilio Gomez-Rubio, Introduction to Sweave. http://pj.freefaculty.org/latex/doc/Gomez-Rubio-Intro_Sweave.pdf </li>
<li>Michael Lundholm, Introduction to Sweave. http://pj.freefaculty.org/latex/doc/Lundholm-weaveintro.pdf </li>
</UL>
</body>
</html>
| Name | Last Modified | Size |
|---|---|---|
| 2014-02-12 19:07 | - | |
| 2005-01-19 22:41 | 29k | |
| 2005-01-19 22:41 | 25k | |
| 2007-07-30 18:45 | 31k | |
| 2005-01-20 19:28 | 14k | |
| 2005-08-18 17:21 | 3k | |
| 2009-01-30 16:02 | 512k | |
| 2005-09-27 22:09 | 50k | |
| 2015-09-03 14:30 | 178k | |
| 2009-01-30 16:02 | 7k | |
| 2009-01-30 16:02 | 108k | |
| 2013-02-14 22:10 | 15k | |
| 2009-08-03 03:15 | 29k | |
| 2010-08-25 22:03 | 13k | |
| 2010-08-25 22:03 | 128k | |
| 2009-01-17 08:22 | 2k | |
| 2009-01-17 08:22 | 65k | |
| 2009-01-19 22:27 | 23k | |
| 2009-01-23 05:34 | 397k | |
| 2009-01-17 07:51 | 4k | |
| 2009-01-17 07:51 | 69k |