Escolar Documentos
Profissional Documentos
Cultura Documentos
Ziqian Zhou
Department of Statistics University of Iowa
Outline
A Introduction to L TEX and LYX
Basic LYX Walkthrough Advanced Topics LYX and Sweave LYX and Beamer (and Sweave) References
A Intro: L TEX
A L TEX (pronounced Lah-tech or Laytech, no s) is a markup language. It is not WYSIWYG What You See Is What You Get
A Intro: L TEX
1 2 3 4
Intro: LYX
1 2
A LYXis a graphical editor built on top of a L TEX processor. It is not WYSIWYG either. It is WYSIWYM (What You See Is What You Mean) Eg. You CANNOT add distance by adding more than one spaces and you CANNOT change layout by clicking and dragging. A It displays most L TEX eects while editing but it does NOT compile while editing.
Installing LYX
Download the latest LYX from lyx.org or install from package manager (linux). This tutorial is based LYX 2.0.2. Alternatively, you can compile LYX directly from source, that enable you to use the latest beta version.
1 2
File -> New (or click icon) Lets type something. Can you type two spaces between two words? Want will \ do? Preview this document by View -> View[PDF(pdatex)] (or click icon)
Text Style
Change the font, size, color and italicize etc.
A What is going on? View the L TEX code: View -> View Source
Text Style
Change the font, size, color and italicize etc.
A What is going on? View the L TEX code: View -> View Source
A Directly insert a picture or table. (Equivalent to L TEX code \includegraphics and \begin{tabular}) Insert -> Table or Insert -> Graphics Floating tables and gures will be placed automatically to achieve best layout.
1
2 3
4 5
Insert -> Float -> Figure/Table A (Equivalent to L TEX figure and table environment.) Insert the table or graphics. For graphics: In the dialog, you can set scaling, rotations etc. Reopen this dialog by clicking the graphics. Use Paragraphic Setting to put it at the center. Right click the gray oat label to change placement options.
Math Editor
1 2
Simply click on Insert -> Math -> Inline formula or Display formula.
A Start typing! Like you do in L TEX. LYX will automatically complete math command for you.
Use math toolbar. View -> Toolbars -> Math etc. You can insert matrix, case and symbols by clicking. Dene math marco: Insert -> Math -> Marco
A If you have an existing L TEX le, you can import it into LYX You can also import Table(CSV), RTF le, and ?Sweave? File -> Import A Since LYXuses L TEX engine, it can be exported .tex source le and any A format L TEX supports. Eg. DVI, HTML, Open Document, etc. You can choose to use many dierent typesetting engines. (Default is pdatex) File -> Export
Cross Reference
1 2
Insert -> Label (\label{}) name a formula gure or table. Insert -> Cross-reference (\ref{}) to refer to it. (Figure 7)
Citation
Go to the place in your document where you want the references to be presented (presumably, the end. You can also have reference at the end of each section). Insert -> Lists & TOC -> BibTEX Bibliography In the dialog, add -> browse look for the .bib le where your bibliography is stored. You can add multiple libraries... Back in Menu, change style. See various styles in http://www.mackichan.com/index.html? techtalk/632.htm~mainFrame Insert -> Citation to cite in the text.
3 4
1 2
If you use Zotero and LYX, you should use LyZ to connect them. Zotero is a Firefox plugin that allows you to collect and manage citation info, abstract, PDF from arXiv.org, journal website or library/amazon catalog. LyZ is a plug-in that connects Zotero and LYX. The citation information in Zotero can be exported to BibTex le and the LYX document by one-click. Instructions see: http://www.klubko.net/wp/?page_id=945&lang=en
Document Settings
A Document Class: setting L TEX preamble \documentclass Page Layout: choose page size etc.
Float Placement: Eg: Set global oat placement to be Here denitely. ( \begin{Figure}[H] ) Change default font, bullet style, color, page margin etc.
A What if there isnt a button corresponding to the L TEX command you want?
1 2
3 2
A You CANNOT change the L TEX source directly. A You insert raw LTEX command as ERT (Evil Red Text) in your document. A Or, you can insert raw L TEX command into document preamble.
A LYXwill not be able to display the result of raw L TEX code. A Inserting raw LTEX code will make it more error-prone. If you have a full latex le, importing it into LYXwould be better.
Preamble A Document -> Settings -> L TEX Preamble If package simpsons has been installed, add: \usepackage{simpsons} When to use ERT?
A You have a big trunk of L TEX code (e.g. a table) 3 When you want to do something fancy, like this, add [3] after the \item. 2 Or when you want to use commands from third-party packages.
1
\Bart
\Left\Homer
Key Bindings
A LYX is not faster than a good L TEX editor. AUCTEX in Emacs has key binding for fonts, environments and math symbols. Customized key bindings in LYX: Preference -> Editing -> Shortcuts Choose shortcut style and search for key-bindings
Sweave
Workow
A .Rnw le contains L TEX and R codes
Sweave
R code chunk begins after <<>>= and ends before @ In R, run: Sweave(file.Rnw) to generate a file.tex le.
1 2
Document -> Settings -> Modules Select Sweave Set global Sweave options at the beginning of the document: Insert -> Custom Insets -> Sweave Options E.g. echo=FALSE to suppress all R code Write R code in LYX: Switch to the Chunk environment in the layout styles list.
For more detail: Ocial LyX manual for Sweave. (Do not use tutorials based on LYX version 1.X)
Beamer
A Beamer is a L TEX class for creating slides for presentations. This presentation is made using Beamer in LYX.
To use Beamer in LYX: Document -> Settings -> Document Classes: Choose Presentation (Beamer ) The better way: modify a template.
Beamer examples: http://wiki.lyx.org/Examples/Beamer LYX le for this presentation: http://www.stat.uiowa.edu/~ziqzhou/files/lyx-how-to.lyx
Frames are the environment for dening slides. You can do basically anything (and more) in frames that you can do in a A simple L TEX document To add a frame: Switch to the BeginFrame environment in the layout styles list This allows you to present things in any order. You can also use overlay specications to create overlays. Add ERT <4-> after \item if you want this to the 4th item to appear.
Frames are the environment for dening slides. You can do basically anything (and more) in frames that you can do in a A simple L TEX document To add a frame: Switch to the BeginFrame environment in the layout styles list This allows you to present things in any order. You can also use overlay specications to create overlays. Add ERT <4-> after \item if you want this to the 4th item to appear.
Frames are the environment for dening slides. You can do basically anything (and more) in frames that you can do in a A simple L TEX document To add a frame: Switch to the BeginFrame environment in the layout styles list This allows you to present things in any order. You can also use overlay specications to create overlays. Add ERT <4-> after \item if you want this to the 4th item to appear.
Frames are the environment for dening slides. You can do basically anything (and more) in frames that you can do in a A simple L TEX document To add a frame: Switch to the BeginFrame environment in the layout styles list This allows you to present things in any order. You can also use overlay specications to create overlays. Add ERT <4-> after \item if you want this to the 4th item to appear.
A Eample Block
You can have boxed texts by using Block or Theorem Switch to various Block or Theorems environment in the layout styles list.
Theorem
Insert pause environment from the layout styles list to achieve an overlay eect.
A Eample Block
You can have boxed texts by using Block or Theorem Switch to various Block or Theorems environment in the layout styles list.
Theorem
Insert pause environment from the layout styles list to achieve an overlay eect.
We can use Sweave and Beamer together in LYX Set Document Class to presentation (beamer) Add Sweave module. There is an incompatibility between Sweave and Beamer. Need to install and use Beamer Fragile module. For more information about how to install it: http://wiki.lyx.org/Layouts/Modules
References
Yihui Xies Sweave-LyX page Ocial LyX manual for Sweave. Use Sweave in Beamer: Beamer Fragile Module Some LYX tricks: http://www2.warwick.ac.uk/fac/soc/ economics/staff/phd_students/yerushalmi/computing/lyx/ LYX wiki tutorial page: http://wiki.lyx.org/LyX/Tutorials