This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
latex_and_sweave [2012/11/20 11:13] zuo created |
latex_and_sweave [2013/07/23 09:13] (current) zuo |
||
|---|---|---|---|
| Line 5: | Line 5: | ||
| \usepackage{amsmath,mathrsfs,stmaryrd,graphicx} | \usepackage{amsmath,mathrsfs,stmaryrd,graphicx} | ||
| \usepackage[top=2cm,bottom=2cm,left=2cm,right=1cm]{geometry} | \usepackage[top=2cm,bottom=2cm,left=2cm,right=1cm]{geometry} | ||
| - | \usepackage[utf8]{inputenc}%used with sweave | ||
| - | \SweaveOpts{engine=R,eps=FALSE,pdf=TRUE,width=3,height=6.5,strip.white=all}%used with sweave | ||
| \title{...} | \title{...} | ||
| Line 23: | Line 21: | ||
| </code> | </code> | ||
| - | ==Convert tiff to eps== | + | ===Use natbib=== |
| - | tiff2ps -e input.tif > output.eps | + | |
| - | Must output encapsulated eps; otherwise the figure can not be located correctly in the latex. | + | <code> |
| + | \usepackage{natbib} | ||
| + | ... | ||
| + | %use bib | ||
| + | \bibliographystyle{apalike} | ||
| + | \bibliography{bib file name without .bib} | ||
| + | </code> | ||
| - | ==Compile .bib== | + | When compile, |
| + | |||
| + | <code> | ||
| latex file.tex | latex file.tex | ||
| bibtex file | bibtex file | ||
| Line 34: | Line 39: | ||
| latex file.tex | latex file.tex | ||
| dvipdf file.dvi | dvipdf file.dvi | ||
| + | </code> | ||
| - | ==Sweave== | + | ===Convert tiff to eps=== |
| + | tiff2ps -e input.tif > output.eps | ||
| + | |||
| + | Must output encapsulated eps; otherwise the figure can not be located correctly in the latex. | ||
| + | |||
| + | ===Sweave=== | ||
| in .rnw file | in .rnw file | ||
| <code> | <code> | ||
| + | \usepackage[utf8]{inputenc}%used with sweave | ||
| + | \SweaveOpts{engine=R,eps=FALSE,pdf=TRUE,width=3,height=6.5,strip.white=all}%used with sweave | ||
| + | |||
| \SweaveOpts{engine=R,eps=FALSE,pdf=TRUE,width=3,height=6.5,strip.white=all} | \SweaveOpts{engine=R,eps=FALSE,pdf=TRUE,width=3,height=6.5,strip.white=all} | ||
| .. | .. | ||
| Line 53: | Line 67: | ||
| </code> | </code> | ||
| + | To control R output line length, | ||
| + | |||
| + | <code> | ||
| + | <<...>>= | ||
| + | options(width=60) | ||
| + | @ | ||
| + | </code> | ||
| + | |||
| + | To control Sweave-generated figures' sizes, | ||
| + | |||
| + | <code> | ||
| + | <<... fig=T,width=4,height=4>>= | ||
| + | ... | ||
| + | @ | ||
| + | </code> | ||
| + | |||
| + | To formulate the Soutput, paste following in Sweave.sty | ||
| + | |||
| + | <code> | ||
| + | \DefineVerbatimEnvironment{Sinput}{Verbatim} {xleftmargin=2em} | ||
| + | \DefineVerbatimEnvironment{Soutput}{Verbatim}{xleftmargin=2em} | ||
| + | \DefineVerbatimEnvironment{Scode}{Verbatim}{xleftmargin=2em} | ||
| + | \fvset{listparameters={\setlength{\topsep}{0pt}}} | ||
| + | \renewenvironment{Schunk}{\vspace{\topsep}}{\vspace{\topsep}} | ||
| + | </code> | ||
| + | |||
| + | ===Set Page Format=== | ||
| + | <code> | ||
| + | |||
| + | \usepackage{fancyhdr} | ||
| + | \pagestyle{fancy} | ||
| + | \fancyhead{} % clear all header fields | ||
| + | \fancyhead[C]{Chandler Zuo} | ||
| + | \fancyhead[L]{} | ||
| + | \fancyhead[R]{UW Madison} | ||
| + | \fancyfoot{} % clear all footer fields | ||
| + | \fancyfoot[C]{\textbf{Page \thepage}} | ||
| + | |||
| + | </code> | ||
| + | |||
| + | |||
| + | ===Animate=== | ||
| + | <code> | ||
| + | \usepackage{animate} | ||
| + | |||
| + | \animategraphics[width=0.9\textwidth]{<frame rate>}{<pdf_file_name_without_.pdf>}{<first frame>}{<last frame>} | ||
| + | </code> | ||
| + | |||
| + | ===Diagram=== | ||
| + | <code> | ||
| + | \usepackage{tikz} | ||
| + | \usetikzlibrary{positioning,shapes,snakes,arrows} | ||
| + | \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm, | ||
| + | bin/.style={rectangle,minimum width=1.9cm,minimum height=0.15cm,line width=0.015cm,fill=blue!50,draw,font=\sffamily\normalsize\bfseries}, | ||
| + | read/.style={draw=none,fill=orange!50,font=\sffamily\tiny\bfseries}, | ||
| + | count/.style={text centered,draw=none,font=\sffamily\scriptsize\bfseries}, | ||
| + | protein/.style={circle,fill=red!50,text centered,draw,font=\sffamily\tiny\bfseries}, | ||
| + | rate/.style={ellipse,text centered,draw=none,fill=green!80,font=\sffamily\small\bfseries}, | ||
| + | hyper/.style={ellipse,text centered,draw=none,fill=pink!80,font=\sffamily\small\bfseries}] | ||
| + | \matrix[nodes={draw, ultra thick, fill=red!20}, row sep=0cm,column sep=0cm,ampersand replacement=\&] { | ||
| + | \node[bin](1){};\& \node[bin](2){};\& \node[bin](3){};\& \node[bin](4){};\& \node[bin](5){};\\ | ||
| + | }; | ||
| + | \node[hyper](input)[rectangle,fill=none,above = 2.9cm of 3]{Input Reads}; | ||
| + | \node[read](read1)[above right=0.4cm and 1.2cm of 3]{...................CACTTT}; | ||
| + | \node[count](x1)[below=0.3cm of 1]{$X_1=2$}; | ||
| + | \node[rate](lambda5)[below=1cm of x5]{$\lambda^z_5$}; | ||
| + | \node[hyper](fun)[fill=red!80,below=2.5cm of x3]{$\mu_i=f(M_i,GC_i)$}; | ||
| + | \node[rate](lambday1)[below=6cm of x1]{$\lambda^y_1$}; | ||
| + | \node[count](y1)[below=1cm of lambday1]{$Y_1=3$}; | ||
| + | % \matrix[nodes={draw, ultra thick, fill=red!20}, row sep=0cm,column sep=0cm,ampersand replacement=\&] { | ||
| + | \node[bin](bin1)[below=0.3cm of y1]{};\& \node[bin](bin2)[below=0.3cm of y2]{};\& \node[bin](bin3)[below=0.3cm of y3]{};\& \node[bin](bin4)[below=0.3cm of y4]{};\& \node[bin](bin5)[below=0.3cm of y5]{};\\ | ||
| + | % }; | ||
| + | % \matrix[nodes={draw, ultra thick, fill=red!20}, row sep=0cm,column sep=0cm,ampersand replacement=\&] { \node[bin](bin1){};\& \node[bin](bin2){};\& \node[bin](bin3){};\& \node[bin](bin4){};\& \node[bin](bin5){};\\ }; | ||
| + | \node[protein](protein1)[above right=-0.3cm and -1cm of bin2]{protein}; | ||
| + | \node[read](read1)[below right=0.2cm and -0.7cm of bin1]{ACCGAC...................}; | ||
| + | \node[hyper](fig)[below=0.1cm of chip,fill=none,rectangle]{\scriptsize \textit{Fig. 2: The hierarchical Bayesian model for bin-level couts.}}; | ||
| + | |||
| + | \path[every node/.style={font=\sffamily\small}] | ||
| + | (lambda1) edge (x1) | ||
| + | (fun) edge (lambday5) | ||
| + | (lambday5) edge (y5); | ||
| + | |||
| + | \node[rate](B1)[above left=0.5cm and -0.5cm of lambday1]{$B_1=0$}; | ||
| + | \node[rate](B5)[above left=0.5cm and -0.50cm of lambday5]{$B_5=0$}; | ||
| + | \path[every node/.style={font=\sffamily\small}] | ||
| + | (B1)edge(lambday1) | ||
| + | (B5)edge(lambday5); | ||
| + | |||
| + | \end{tikzpicture} | ||
| + | </code> | ||