<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Statistics, R, Graphics and Fun &#187; LaTeX</title>
	<atom:link href="http://yihui.name/en/tag/latex/feed/" rel="self" type="application/rss+xml" />
	<link>http://yihui.name/en</link>
	<description>Yihui XIE</description>
	<lastBuildDate>Fri, 23 Jul 2010 16:33:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Font Families for the R PDF Device</title>
		<link>http://yihui.name/en/2010/03/font-families-for-the-r-pdf-device/</link>
		<comments>http://yihui.name/en/2010/03/font-families-for-the-r-pdf-device/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 16:12:25 +0000</pubDate>
		<dc:creator>Yihui Xie</dc:creator>
				<category><![CDATA[R Graphics]]></category>
		<category><![CDATA[AvantGarde]]></category>
		<category><![CDATA[Bookman]]></category>
		<category><![CDATA[Courier]]></category>
		<category><![CDATA[Font Family]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Helvetica]]></category>
		<category><![CDATA[Helvetica-Narrow]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[NewCenturySchoolbook]]></category>
		<category><![CDATA[Palatino]]></category>
		<category><![CDATA[pdf()]]></category>
		<category><![CDATA[pdf.options()]]></category>
		<category><![CDATA[pgfSweave]]></category>
		<category><![CDATA[Sweave]]></category>
		<category><![CDATA[Times]]></category>

		<guid isPermaLink="false">http://yihui.name/en/?p=472</guid>
		<description><![CDATA[otivated by the excellent R package pgfSweave, I begin to notice the font families in my graphs when writing Sweave documents. The default font family for PDF graphs is Helvetica, which is, in most cases (I think), inconsistent with the LaTeX font styles. Some common font families are listed in ?postscript, and we can take [...]]]></description>
			<content:encoded><![CDATA[<a href="http://yihui.name/en/2010/03/font-families-for-the-r-pdf-device/"><span class="dropcap">M</span></a>otivated by the excellent R package <code>pgfSweave</code>, I begin to notice the font families in my graphs when writing Sweave documents. The default font family for PDF graphs is <code>Helvetica</code>, which is, in most cases (I think), inconsistent with the LaTeX font styles. Some common font families are listed in <code>?postscript</code>, and we can take a look at them by:</p>
<pre>for (f in c("AvantGarde", "Bookman", "Courier", "Helvetica",
    "Helvetica-Narrow", "NewCenturySchoolbook", "Palatino", "Times")) {
    pdf.options(family = f)
    pdf(paste(f, ".pdf", sep = ""))
    set.seed(123)
    plot(rnorm(25), pch = 1:25, xlab = "xlab family", ylab = "ylab font",
        main = paste("Font Families in R (PDF):", f))
    text(13, 0, "Text in the Middle")
    mtext(sprintf("pdf.options(family = \"%s\")", f), side = 4)
    dev.off()
}
</pre>
<p>Here is a merged PDF containing the above single PDF files:</p>
<p><span class="download"><a href="http://yihui.name/en/wp-content/uploads/2010/03/R-PDF-font-families.pdf">R-PDF-font-families.pdf  (29K)</a></span>
<p>It seems that <code>"Bookman"</code>, <code>"NewCenturySchoolbook"</code>, <code>"Palatino"</code> and <code>"Times"</code> can be better choices when using Sweave because they are serif fonts, which are usually more consistent with LaTeX PDF.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://yihui.name/en/2010/02/press-enter-in-lyx-sweave-as-you-wish/" title="Press Enter in LyX Sweave as You Wish">Press Enter in LyX Sweave as You Wish</a></li><li><a href="http://yihui.name/en/2009/11/create-animations-in-pdf-documents-using-r/" title="Create Animations in PDF Documents Using R">Create Animations in PDF Documents Using R</a></li><li><a href="http://yihui.name/en/2008/10/how-to-open-a-file-from-a-hyperlink/" title="How to Open a File from a Hyperlink">How to Open a File from a Hyperlink</a></li><li><a href="http://yihui.name/en/2007/09/semi-transparent-colors-in-r-color-image-as-an-example/" title="Semi-transparent Colors in R: Color Image as an Example">Semi-transparent Colors in R: Color Image as an Example</a></li><li><a href="http://yihui.name/en/2009/10/50000-revisions-committed-to-r/" title="50000 Revisions Committed to R">50000 Revisions Committed to R</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://yihui.name/en/2010/03/font-families-for-the-r-pdf-device/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Press Enter in LyX Sweave as You Wish</title>
		<link>http://yihui.name/en/2010/02/press-enter-in-lyx-sweave-as-you-wish/</link>
		<comments>http://yihui.name/en/2010/02/press-enter-in-lyx-sweave-as-you-wish/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 19:15:55 +0000</pubDate>
		<dc:creator>Yihui Xie</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[R Programming]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[LyX]]></category>
		<category><![CDATA[pgfSweave]]></category>
		<category><![CDATA[R Language]]></category>
		<category><![CDATA[Scrap]]></category>
		<category><![CDATA[Sweave]]></category>

		<guid isPermaLink="false">http://yihui.name/en/?p=443</guid>
		<description><![CDATA[or a long time I&#8217;ve been wondering why we are not able to use Enter in the LyX Scrap environment which was set up by Gregor Gorjanc for Sweave. Two weeks ago, I (finally!) could not help asking Gregor about this issue, as I&#8217;m using &#8220;LyX + Sweave&#8221; more and more in my daily work. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://yihui.name/en/2010/02/press-enter-in-lyx-sweave-as-you-wish/"><span class="dropcap-red">F</span></a>or a long time I&#8217;ve been wondering why we are not able to use Enter in the LyX Scrap environment which was set up by Gregor Gorjanc for Sweave. Two weeks ago, I (finally!) could not help asking Gregor about this issue, as I&#8217;m using &#8220;LyX + Sweave&#8221; more and more in my daily work. He explained it here: <a href="http://ggorjan.blogspot.com/2009/07/lyx-sweave-mandatory-use-of.html">LyX-Sweave: mandatory use of control+enter in code chunks</a></p>
<p>After digging into the LyX customization manual for a while, I found a solution which allows us to press the Enter key just as we normally do when typing in a LyX document. The key is to use <code>Environment</code> instead of <code>paragraph</code> as <code>LatexType</code> for the style definition of <code>Scrap</code>. Besides, I used the <code>LatexName</code> as <code>wrapsweave</code>, as a <code>LatexName</code> is required by LyX. The definition for <code>wrapsweave</code> is simple: just two empty lines by <code>\par</code>. (If you define it as <code>\newenvironment{wrapsweave}{}{}</code>, you will run into troubles sometimes; especially when you use indent for paragraphs.)</p>
<p>As we know, LaTeX environment cannot be centered in LyX (only paragraphs can), so I defined a special environment <code>ScrapCenter</code> when I want to insert graphics via Sweave and make them center-aligned.<span id="more-443"></span></p>
<p>To put all efforts together, this is the new <code>literate-scrap.inc</code> (compare it with <a href="http://cran.r-project.org/contrib/extra/lyx/literate-scrap.inc">http://cran.r-project.org/contrib/extra/lyx/literate-scrap.inc</a>):</p>
<pre>Format 2

Preamble
\usepackage{Sweave}
\newenvironment{wrapsweave}{\par}{\par}
EndPreamble

OutputType              literate

Style Scrap
  LatexType             Environment
  LatexName             wrapsweave
  Margin                static
  TopSep                0.4
  BottomSep             0.4
  ParSep                0.0
  LabelType             static
  Align                 left
  AlignPossible         block, left, right, center
  NewLine               0
  PassThru              1
  FreeSpacing           1
  TextFont
    Color               latex
    Family              typewriter
  EndFont
End

Style ScrapCenter
  LatexType             Environment
  LatexName             center
  Margin                static
  TopSep                0.4
  BottomSep             0.4
  ParSep                0.0
  LabelType             static
  Align                 center
  NewLine               0
  PassThru              1
  FreeSpacing           1
  TextFont
    Color               latex
    Family              typewriter
  EndFont
End
</pre>
<p>Enjoy pressing a single Enter key in LyX now! <img src='http://yihui.name/en/wp-content/plugins/tango-smilies/tango/face-smile.png' alt=':)' class='wp-smiley' /> </p>
<p>P.S. the side effect of this modification is, your R code will be separated by empty lines. But Sweave will remove blank lines by default, so that is not really a big trouble.</p>
<p>P.P.S. Next time I will write my solution of using <code>pgfSweave</code> in LyX &#8212; if you have never tried the <code>pgfSweave</code> package in R, I&#8217;d strongly recommend you do it right now!! My comment on this package is: amazingly beautiful! See a preview <a href="http://yihui.name/en/wp-content/uploads/2010/02/lyx-pgfsweave-demo.pdf">lyx-pgfsweave-demo</a>.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://yihui.name/en/2010/03/font-families-for-the-r-pdf-device/" title="Font Families for the R PDF Device">Font Families for the R PDF Device</a></li><li><a href="http://yihui.name/en/2009/11/create-animations-in-pdf-documents-using-r/" title="Create Animations in PDF Documents Using R">Create Animations in PDF Documents Using R</a></li><li><a href="http://yihui.name/en/2010/04/r-is-an-epic-fail/" title="R is an Epic Fail?">R is an Epic Fail?</a></li><li><a href="http://yihui.name/en/2010/03/looking-for-software-paths-in-windows-registry/" title="Looking for Software Paths in Windows Registry">Looking for Software Paths in Windows Registry</a></li><li><a href="http://yihui.name/en/2010/03/a-demo-for-the-ratio-estimation/" title="A Demo for the Ratio Estimation in Sampling Survey (Animation)">A Demo for the Ratio Estimation in Sampling Survey (Animation)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://yihui.name/en/2010/02/press-enter-in-lyx-sweave-as-you-wish/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Create Animations in PDF Documents Using R</title>
		<link>http://yihui.name/en/2009/11/create-animations-in-pdf-documents-using-r/</link>
		<comments>http://yihui.name/en/2009/11/create-animations-in-pdf-documents-using-r/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 02:37:21 +0000</pubDate>
		<dc:creator>Yihui Xie</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[R Graphics]]></category>
		<category><![CDATA[R Programming]]></category>
		<category><![CDATA[animate]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[pdf()]]></category>
		<category><![CDATA[pdflatex]]></category>
		<category><![CDATA[R Language]]></category>

		<guid isPermaLink="false">http://yihui.name/en/?p=335</guid>
		<description><![CDATA[ince animation 1.0-9, we will be able to create a PDF document with an animation embedded in it; the function is saveLatex(), and its usage is similar to saveMovie() and saveSWF(): you pass an R expression for creating animations to this function, and this expression will be evaluated in the function; the image frames get [...]]]></description>
			<content:encoded><![CDATA[<a href="http://yihui.name/en/2009/11/create-animations-in-pdf-documents-using-r/"><span class="dropcap-red">S</span></a>ince <code>animation</code> 1.0-9, we will be able to create a PDF document with an animation embedded in it; the function is <code>saveLatex()</code>, and its usage is similar to <code>saveMovie()</code> and <code>saveSWF()</code>: you pass an R expression for creating animations to this function, and this expression will be evaluated in the function; the image frames get recorded by a graphics device. In the end, a LaTeX document is written in a directory, and we can get a PDF document by running <code>pdflatex</code> on the document.</p>
<p>In fact, the key point is the LaTeX package named <code>animate</code>, which can be used to insert image frames into a PDF document to generate an animation. The interface of animations created by this package is quite similar to the HTML animation page by the R package <code>animation</code>, moreover, it also uses JavaScript (in PDF) to animate the image frames.<span id="more-335"></span></p>
<p>Here is an example:</p>
<pre>library(animation)
oopt = ani.options(interval = 0.1, nmax = 100)
## brownian motion: note the 'loop' option and how to set graphics
#    parameters with 'ani.first'
saveLatex({
    brownian.motion(pch = 21, cex = 5, col = "red", bg = "yellow",
        main = "Demonstration of Brownian Motion")
}, ani.basename = "BM", ani.opts = "controls,loop,width=0.8\\textwidth",
    ani.first = par(mar = c(3, 3, 1, 0.5), mgp = c(2, 0.5, 0),
        tcl = -0.3, cex.axis = 0.8, cex.lab = 0.8, cex.main = 1),
    latex.filename = "brownian.motion.tex")
ani.options(oopt)</pre>
<p><span class="download">Download the demo: <a href="http://yihui.name/en/wp-content/uploads/2009/11/brownian.motion.pdf">Brownian Motion in PDF</a> (205K)</span>
<p>The PDF document will be automatically opened if there is nothing wrong with <code>LaTeX</code> and your PDF viewer; if nothing happened, you can find the PDF document <code>brownian.motion.pdf</code> in the directory <code>ani.options("outdir")</code>.</p>
<p>The animation will work in Acrobat Reader 9.0, and I do not know if other PDF viewers can deal with JavaScript correctly (AFAIK, the default PDF viewer in Mac OS will not).</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://yihui.name/en/2010/03/a-demo-for-the-ratio-estimation/" title="A Demo for the Ratio Estimation in Sampling Survey (Animation)">A Demo for the Ratio Estimation in Sampling Survey (Animation)</a></li><li><a href="http://yihui.name/en/2010/03/font-families-for-the-r-pdf-device/" title="Font Families for the R PDF Device">Font Families for the R PDF Device</a></li><li><a href="http://yihui.name/en/2010/02/press-enter-in-lyx-sweave-as-you-wish/" title="Press Enter in LyX Sweave as You Wish">Press Enter in LyX Sweave as You Wish</a></li><li><a href="http://yihui.name/en/2009/12/happy-new-year-with-r/" title="Happy New Year with R">Happy New Year with R</a></li><li><a href="http://yihui.name/en/2009/12/merry-christmas-using-r/" title="Merry Christmas Using R">Merry Christmas Using R</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://yihui.name/en/2009/11/create-animations-in-pdf-documents-using-r/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to Open a File from a Hyperlink</title>
		<link>http://yihui.name/en/2008/10/how-to-open-a-file-from-a-hyperlink/</link>
		<comments>http://yihui.name/en/2008/10/how-to-open-a-file-from-a-hyperlink/#comments</comments>
		<pubDate>Sun, 12 Oct 2008 06:56:20 +0000</pubDate>
		<dc:creator>Yihui Xie</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[hyperlink]]></category>
		<category><![CDATA[hyperref]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[pdf()]]></category>
		<category><![CDATA[run]]></category>

		<guid isPermaLink="false">http://yihui.name/en/?p=54</guid>
		<description><![CDATA[&#8216;d like to thank Prof Michael Friendly for telling me this: just create a hyperlink to the file with the run protocol and then you can open a file directly from the hyperlink. For example, in LaTeX with hyperref package, you may use \href{run:path/to/some.file}{some link} to open this some.file in your PDF. This is a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://yihui.name/en/2008/10/how-to-open-a-file-from-a-hyperlink/"><span class="dropcap-brown">I</span></a>&#8216;d like to thank <a title="http://www.math.yorku.ca/SCS/friendly.html" href="http://www.math.yorku.ca/SCS/friendly.html" target="_blank">Prof Michael Friendly</a> for telling me this: just create a hyperlink to the file with the <strong><code>run</code></strong> protocol and then you can open a file directly from the hyperlink. For example, in LaTeX with hyperref package, you may use <code>\href{run:path/to/some.file}{some link}</code> to open this <code>some.file</code> in your PDF. This is a useful hack that I have been looking for over a long time.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://yihui.name/en/2010/03/font-families-for-the-r-pdf-device/" title="Font Families for the R PDF Device">Font Families for the R PDF Device</a></li><li><a href="http://yihui.name/en/2009/11/create-animations-in-pdf-documents-using-r/" title="Create Animations in PDF Documents Using R">Create Animations in PDF Documents Using R</a></li><li><a href="http://yihui.name/en/2010/02/press-enter-in-lyx-sweave-as-you-wish/" title="Press Enter in LyX Sweave as You Wish">Press Enter in LyX Sweave as You Wish</a></li><li><a href="http://yihui.name/en/2008/09/eyeball-test-to-identify-an-unfair-coin/" title="&#8220;Eyeball Test&#8221; to Identify An Unfair Coin (or A False Record)">&#8220;Eyeball Test&#8221; to Identify An Unfair Coin (or A False Record)</a></li><li><a href="http://yihui.name/en/2008/06/dokuwiki-plugins-animation-and-math-added/" title="Dokuwiki Plugins &#8220;animation&#8221; and &#8220;math&#8221; Added">Dokuwiki Plugins &#8220;animation&#8221; and &#8220;math&#8221; Added</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://yihui.name/en/2008/10/how-to-open-a-file-from-a-hyperlink/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Dokuwiki Plugins &#8220;animation&#8221; and &#8220;math&#8221; Added</title>
		<link>http://yihui.name/en/2008/06/dokuwiki-plugins-animation-and-math-added/</link>
		<comments>http://yihui.name/en/2008/06/dokuwiki-plugins-animation-and-math-added/#comments</comments>
		<pubDate>Wed, 04 Jun 2008 15:55:11 +0000</pubDate>
		<dc:creator>Yihui Xie</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[AniWiki]]></category>
		<category><![CDATA[Dokuwiki]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://yihui.name/en/?p=44</guid>
		<description><![CDATA[have spent three days on these two plugins. The first one &#8220;animation&#8221; is written by myself after a quick view of the instructions on writing plugins for Dokuwiki, as there is no such kind of plugins so far. What I want to say is &#8220;Regular expression is really a devil&#8221;! It has almost taken me [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://yihui.name/en/2008/06/dokuwiki-plugins-animation-and-math-added/"><span class="dropcap-blue">I</span></a> have spent three days on these two plugins. The first one &#8220;<code><a title="Dokuwiki plugin 'animation'" href="http://animation.yihui.name/wiki:animation_plugin" target="_blank">animation</a></code>&#8221; is written by myself after a quick view of the instructions on writing plugins for Dokuwiki, as there is no such kind of plugins so far. What I want to say is &#8220;Regular expression is really a devil&#8221;! It has almost taken me a whole day to understand how to use a correct pattern to match the parameters in the tags&#8230;</p>
<p>Then I modified the &#8220;<code><a title="Dokuwiki plugin math" href="http://wiki.splitbrain.org/plugin:math" target="_blank">math</a></code>&#8221; plugin so that it is much easier and more familiar for us to type LaTeX formulae in the wiki pages: just use <code>$...$</code> or <code>$$...$$</code>. People who are familiar with LaTeX surely know what they mean.</p>
<p>By the way, <a title="http://www.sciviews.org/_phgrosjean" href="http://www.sciviews.org/_phgrosjean" target="_blank">Philippe Grosjean</a> has kindly provided me the necessary files for highlighting R code in the Dokuwiki system. That&#8217;s really fantastic! See <a title="Including mathematical formulae into AniWiki" href="http://animation.yihui.name/wiki:math" target="_blank">this page</a> for some examples.</p>
<p>So the main infrastructure has been built till now; the next step is to modify my <a title="R package animation" href="http://cran.r-project.org/package=animation" target="_blank"><code>animation</code></a> package and include more functions which have been in my mind for a long time. Then I will begin to migrate the old web pages in <a title="Animated Statistics Using R" href="http://R.yihui.name" target="_blank">http://R.yihui.name</a> to <code><a title="A Wiki for Statistical Animations" href="http://animation.yihui.name" target="_blank">AniWiki</a></code>.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://yihui.name/en/2009/11/create-animations-in-pdf-documents-using-r/" title="Create Animations in PDF Documents Using R">Create Animations in PDF Documents Using R</a></li><li><a href="http://yihui.name/en/2008/05/aniwiki-animations-in-statistics/" title="AniWiki: Animations in Statistics">AniWiki: Animations in Statistics</a></li><li><a href="http://yihui.name/en/2010/07/my-talk-on-animations-at-user-2010/" title="My Talk on Animations at useR! 2010 (NIST, Gaithersburg)">My Talk on Animations at useR! 2010 (NIST, Gaithersburg)</a></li><li><a href="http://yihui.name/en/2010/04/alphahull-an-r-package-for-alpha-convex-hull/" title="alphahull: an R Package for Alpha-Convex Hull">alphahull: an R Package for Alpha-Convex Hull</a></li><li><a href="http://yihui.name/en/2010/03/a-demo-for-the-ratio-estimation/" title="A Demo for the Ratio Estimation in Sampling Survey (Animation)">A Demo for the Ratio Estimation in Sampling Survey (Animation)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://yihui.name/en/2008/06/dokuwiki-plugins-animation-and-math-added/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Line Breaks for LaTeX Code in R Documentation Files</title>
		<link>http://yihui.name/en/2007/12/line-breaks-for-latex-code-in-r-documentation-files/</link>
		<comments>http://yihui.name/en/2007/12/line-breaks-for-latex-code-in-r-documentation-files/#comments</comments>
		<pubDate>Mon, 31 Dec 2007 05:14:19 +0000</pubDate>
		<dc:creator>Yihui Xie</dc:creator>
				<category><![CDATA[R Language]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[line break]]></category>
		<category><![CDATA[R Documentation]]></category>
		<category><![CDATA[R Package]]></category>

		<guid isPermaLink="false">http://yihui.name/en/?p=29</guid>
		<description><![CDATA[suddenly realized just now that the line breaks for LaTeX code in Rd files are also \cr instead of \\ (which I thought to be in the past). R CMD CHECK will replace your \cr with \\ when producing LaTeX documentation files. If you write \\ directly in Rd files, it will be recognized as [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://yihui.name/en/2007/12/line-breaks-for-latex-code-in-r-documentation-files/"><span class="dropcap-orange">I</span></a> suddenly realized just now that the line breaks for <code>LaTeX</code> code in <acronym title="R Documentation">Rd</acronym> files are also <code>\cr</code> instead of <code>\\</code> (which I thought to be in the past). <code>R CMD CHECK</code> will replace your <code>\cr</code> with <code>\\</code> when producing <code>LaTeX</code> documentation files. If you write <code>\\</code> directly in Rd files, it will be recognized as &#8220;<em>an escape character</em> + <em>a backslash</em>&#8220;, which surely is not a line break symbol.</p>
<p>I found such a problem in the documentation file for the function <a title="Help file" href="http://finzi.psych.upenn.edu/R/library/animation/html/brownian.motion.html" target="_blank"><code>brownian.motion()</code></a> in my package &#8220;<a title="animation pkg on CRAN" href="http://cran.r-project.org/src/contrib/Descriptions/animation.html" target="_blank">animation</a>&#8220;. The original code is:</p>
<pre>\deqn{x_{k + 1} = x_{k} + rnorm(1)<strong>\\
</strong>  y_{k + 1} = y_{k} + rnorm(1)}{x[k + 1] = x[k] + rnorm(1)\cr y[k + 1] = y[k] + rnorm(1)}</pre>
<p>And actually it should be:</p>
<pre>\deqn{x_{k + 1} = x_{k} + rnorm(1)<strong>\cr</strong>
  y_{k + 1} = y_{k} + rnorm(1)}{x[k + 1] = x[k] + rnorm(1)\cr y[k + 1] = y[k] + rnorm(1)}</pre>
<p>I was just to write an email for help but I understood the reason for my problem (by checking the result from <code>R CMD CHECK</code>) before I sent my email.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://yihui.name/en/2010/03/font-families-for-the-r-pdf-device/" title="Font Families for the R PDF Device">Font Families for the R PDF Device</a></li><li><a href="http://yihui.name/en/2010/02/press-enter-in-lyx-sweave-as-you-wish/" title="Press Enter in LyX Sweave as You Wish">Press Enter in LyX Sweave as You Wish</a></li><li><a href="http://yihui.name/en/2009/11/create-animations-in-pdf-documents-using-r/" title="Create Animations in PDF Documents Using R">Create Animations in PDF Documents Using R</a></li><li><a href="http://yihui.name/en/2008/10/how-to-open-a-file-from-a-hyperlink/" title="How to Open a File from a Hyperlink">How to Open a File from a Hyperlink</a></li><li><a href="http://yihui.name/en/2008/06/flash-animations-by-saveswf-in-package-animation/" title="Flash Animations by saveSWF() in Package &#8220;animation&#8221;">Flash Animations by saveSWF() in Package &#8220;animation&#8221;</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://yihui.name/en/2007/12/line-breaks-for-latex-code-in-r-documentation-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Slight Changes to Boadilla Theme in Beamer Class</title>
		<link>http://yihui.name/en/2007/10/slight-changes-to-boadilla-theme-in-beamer-class/</link>
		<comments>http://yihui.name/en/2007/10/slight-changes-to-boadilla-theme-in-beamer-class/#comments</comments>
		<pubDate>Fri, 19 Oct 2007 07:16:01 +0000</pubDate>
		<dc:creator>Yihui Xie</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[beamer]]></category>
		<category><![CDATA[Boadilla]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[theme]]></category>

		<guid isPermaLink="false">http://yihui.name/en/?p=14</guid>
		<description><![CDATA[Boadilla&#8221; is a quite plain theme in beamer class; I like plain styles, but I also want a headline in the top indicating the sections so that I can know where I am when I&#8217;m giving a speech. Thus I gave some slight changes to this plain theme: the default headline has been replaced with [...]]]></description>
			<content:encoded><![CDATA[<a href="http://yihui.name/en/2007/10/slight-changes-to-boadilla-theme-in-beamer-class/"><span class="dropcap-grey">&#8220;</span></a><code>Boadilla</code>&#8221; is a quite plain theme in beamer class; I like plain styles, but I also want a headline in the top indicating the sections so that I can know where I am when I&#8217;m giving a speech. Thus I gave some slight changes to this plain theme: the <code>default</code> headline has been replaced with &#8220;<code>infolines</code>&#8220;, while the definition of the <em>outer theme</em> &#8220;<code>infolines</code>&#8221; has also been modified as I don&#8217;t have any <em>subsections</em>.</p>
<p>The original headline:</p>
<pre>\ifbeamer@secheader\else\setbeamertemplate{headline}[default]\fi</pre>
<p>The modified version:</p>
<pre>\ifbeamer@secheader\else\setbeamertemplate{headline}[infolines]\fi</pre>
<div style="text-align: center;"><a title="Boadilla Theme without headlines" href="http://yihui.name/en/wp-content/uploads/1192781106_1.png"><img src="http://yihui.name/en/wp-content/uploads/1192781106_0.png" border="0" alt="" /></a> <a title="Boadilla Theme with headlines" href="http://yihui.name/en/wp-content/uploads/1192781122_1.png"><img src="http://yihui.name/en/wp-content/uploads/1192781122_0.png" border="0" alt="" /></a></div>
<p><span class="download"><a href="http://yihui.name/en/wp-content/uploads//1192775346_0.zip">Downdload the file here</a></span>
<p>You may visit <a href="http://yihui.name/en/2007/10/jokes-in-statistics-a-talk-to-be-given-in-cueb/">http://yihui.name/en/2007/10/jokes-in-statistics-a-talk-to-be-given-in-cueb/</a> to see the effects of my modifications.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://yihui.name/en/2010/03/font-families-for-the-r-pdf-device/" title="Font Families for the R PDF Device">Font Families for the R PDF Device</a></li><li><a href="http://yihui.name/en/2010/02/press-enter-in-lyx-sweave-as-you-wish/" title="Press Enter in LyX Sweave as You Wish">Press Enter in LyX Sweave as You Wish</a></li><li><a href="http://yihui.name/en/2009/11/create-animations-in-pdf-documents-using-r/" title="Create Animations in PDF Documents Using R">Create Animations in PDF Documents Using R</a></li><li><a href="http://yihui.name/en/2008/10/how-to-open-a-file-from-a-hyperlink/" title="How to Open a File from a Hyperlink">How to Open a File from a Hyperlink</a></li><li><a href="http://yihui.name/en/2008/06/dokuwiki-plugins-animation-and-math-added/" title="Dokuwiki Plugins &#8220;animation&#8221; and &#8220;math&#8221; Added">Dokuwiki Plugins &#8220;animation&#8221; and &#8220;math&#8221; Added</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://yihui.name/en/2007/10/slight-changes-to-boadilla-theme-in-beamer-class/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>multicol &#8212; Multi-column Pages in LaTeX</title>
		<link>http://yihui.name/en/2007/10/multicol-multi-column-pages-in-latex/</link>
		<comments>http://yihui.name/en/2007/10/multicol-multi-column-pages-in-latex/#comments</comments>
		<pubDate>Wed, 03 Oct 2007 09:03:06 +0000</pubDate>
		<dc:creator>Yihui Xie</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[multicol]]></category>

		<guid isPermaLink="false">http://yihui.name/en/?p=10</guid>
		<description><![CDATA[hen I was adjusting my slides for a talk (to be given in Oct 16) in the Capital University of Economics and Business, I found the table of contents was a little bit too long to be placed in a single page while the titles of all sections are not so wide, thus I searched [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://yihui.name/en/2007/10/multicol-multi-column-pages-in-latex/"><span class="dropcap-red">W</span></a>hen I was adjusting my slides for a talk (to be given in Oct 16) in the Capital University of Economics and Business, I found the table of contents was a little bit too long to be placed in a single page while the titles of all sections are not so wide, thus I searched for some instructions on multi-column pages in LaTeX, and easily got this <a title="This site is still unavailable in China mainland..." href="http://en.wikibooks.org" target="_blank">Wikipedia</a> page: <a title="LaTeX Page Layout" href="http://en.wikibooks.org/wiki/LaTeX/Page_Layout" target="_blank">http://en.wikibooks.org/wiki/LaTeX/Page_Layout</a>. Some codes as follows will just help us separate a part of texts into several columns:</p>
<pre>...
\usepackage{multicol}
...
\begin{multicols}{3}    % 3 columns
   If you are using a standard Latex document class,
   then you can simply pass the optional argument twocolumn
   to the document class: \documentclass[twocolumn]{article}
   which will give the desired effect.
\end{multicols}
...</pre>
<p>This is what my table of contents looks like now:</p>
<p><a title="Multi-column Pages in LaTeX" rel="lightbox" href="http://yihui.name/en/wp-content/uploads/1191402784_1.png"><img class="aligncenter" style="border: 0pt none;" src="http://yihui.name/en/wp-content/uploads/1191402784_0.gif" border="0" alt="" width="363" height="272" /></a></p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://yihui.name/en/2010/03/font-families-for-the-r-pdf-device/" title="Font Families for the R PDF Device">Font Families for the R PDF Device</a></li><li><a href="http://yihui.name/en/2010/02/press-enter-in-lyx-sweave-as-you-wish/" title="Press Enter in LyX Sweave as You Wish">Press Enter in LyX Sweave as You Wish</a></li><li><a href="http://yihui.name/en/2009/11/create-animations-in-pdf-documents-using-r/" title="Create Animations in PDF Documents Using R">Create Animations in PDF Documents Using R</a></li><li><a href="http://yihui.name/en/2008/10/how-to-open-a-file-from-a-hyperlink/" title="How to Open a File from a Hyperlink">How to Open a File from a Hyperlink</a></li><li><a href="http://yihui.name/en/2008/06/dokuwiki-plugins-animation-and-math-added/" title="Dokuwiki Plugins &#8220;animation&#8221; and &#8220;math&#8221; Added">Dokuwiki Plugins &#8220;animation&#8221; and &#8220;math&#8221; Added</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://yihui.name/en/2007/10/multicol-multi-column-pages-in-latex/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
