Obviously you are using pgfSweave, and the problem came from the fact that your plot contained a character string "x & y" which is not a legal string in your context (because & is a special character that needs to be escaped).
Two approaches to fix the problem: 1. change the title, e.g. prewhiten(y=diff(bluebird)[,1],x=diff(bluebird)[,2],ylab='CCF', main = 'no special characters here') 2. use sanitize=TRUE in your chunk options (so that & will be replaced by \&); see ?sanitizeTexString in the tikzDevice package for details Regards, Yihui -- Yihui Xie <xieyi...@gmail.com> Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Mon, Jun 27, 2011 at 9:44 PM, Lucas <lth...@mail.unomaha.edu> wrote: > When I try to use the TSA::prewhiten function from within a Sweave (or > pgfSweave, the bug triggers either way it seems) code chunk inside a LyX > document, I get this error: > > 20:35:49.417: Preview: Fontsize 10pt > 20:35:49.418: Preview: PDFoutput 1 > 20:35:49.419: ! Misplaced alignment tab character &. > 20:35:49.420: l.17 ...ale=1.20000004768372] (TeX) {\bfseries x & > 20:35:49.421: y% > 20:35:49.422: Here is how much of TeX's memory you used: > 20:35:49.428: 9510 strings out of 495061 > 20:35:49.429: 179132 string characters out of 1182621 > 20:35:49.430: 210888 words of memory out of 3000000 > 20:35:49.431: 12540 multiletter control sequences out of 15000+50000 > 20:35:49.432: 5179 words of font info for 16 fonts, out of 3000000 for 9000 > 20:35:49.433: 28 hyphenation exceptions out of 8191 > 20:35:49.439: 56i,3n,55p,425b,492s stack positions out of > 5000i,500n,10000p,200000b,50000s > 20:35:49.440: > 20:35:49.441: ! ==> Fatal error occurred, no output PDF file produced! > 20:35:49.442: Error in getMetricsFromLatex(TeXMetrics) : > 20:35:49.443: TeX was unable to calculate metrics for the following string > 20:35:49.444: or character: > 20:35:49.449: > 20:35:49.450: x & y > 20:35:49.451: > 20:35:49.452: Common reasons for failure include: > 20:35:49.453: * The string contains a character which is special to LaTeX > unless > 20:35:49.454: escaped properly, such as % or $. > 20:35:49.455: * The string makes use of LaTeX commands provided by a package > and > 20:35:49.464: the tikzDevice was not told to load the package. > 20:35:49.466: > 20:35:49.468: The contents of the LaTeX log of the aborted run have been > printed > above, > 20:35:49.471: it may contain additional details as to why the metric > calculation > failed. > > Document that reproduces this error (requires a working R+Sweave+LyX setup > with > the 'TSA' R package from > http://cran.r-project.org/web/packages/TSA/index.html): > #LyX 2.0 created this file. For more info see http://www.lyx.org/ > \lyxformat 413 > \begin_document > \begin_header > \textclass article > \use_default_options true > \begin_modules > sweave > \end_modules > \maintain_unincluded_children false > \language english > \language_package default > \inputencoding utf8 > \fontencoding global > \font_roman default > \font_sans default > \font_typewriter default > \font_default_family default > \use_non_tex_fonts false > \font_sc false > \font_osf false > \font_sf_scale 100 > \font_tt_scale 100 > > \graphics default > \default_output_format default > \output_sync 0 > \bibtex_command default > \index_command default > \paperfontsize default > \spacing single > \use_hyperref false > \papersize default > \use_geometry false > \use_amsmath 1 > \use_esint 1 > \use_mhchem 1 > \use_mathdots 1 > \cite_engine basic > \use_bibtopic false > \use_indices false > \paperorientation portrait > \suppress_date false > \use_refstyle 1 > \index Index > \shortcut idx > \color #008000 > \end_index > \secnumdepth 3 > \tocdepth 3 > \paragraph_separation indent > \paragraph_indentation default > \quotes_language english > \papercolumns 1 > \papersides 1 > \paperpagestyle default > \tracking_changes false > \output_changes false > \html_math_output 0 > \html_css_as_file 0 > \html_be_strict false > \end_header > > \begin_body > > \begin_layout Chunk > <<explode,fig=true,height=3,width=5>>= > \end_layout > > \begin_layout Chunk > library(TSA) > \end_layout > > \begin_layout Chunk > data(bluebird) > \end_layout > > \begin_layout Chunk > prewhiten(y=diff(bluebird)[,1],x=diff(bluebird)[,2],ylab='CCF') > \end_layout > > \begin_layout Chunk > @ > \end_layout > > \end_body > \end_document > > --Lucas > > >