Thứ Hai, 30 tháng 4, 2012

[LyX] LyX for common conferences

Latex Usage Notes

Tips, References, etc. for Latex, Lyx, Miktex, Bibtex, etc.

References

Jabref/Bibtex Notes

Latex Only Notes

  • To use Harvard-style of author-year, use the following in the preamble, then use \citep in the text, and don ’t forget to compile three times:
\usepackage{babel}
\usepackage{natbib}

Convert from/to Latex

Making Scientific Posters

Latex Usage Notes

\documentclass[twocolumn]{article}
...
\begin{document}
... % \author, etc
\twocolumn[
  \begin{@twocolumnfalse}
    \maketitle
    \begin{abstract}
      ...
    \end{abstract}
  \end{@twocolumnfalse}
  ]
For lyx, just used:
\twocolumn[
  \begin{@twocolumnfalse}
  ... non-ERT ...
  \vspace{10 mm}
  \end{@twocolumnfalse}
]
  • Make a title:
\newcommand{\makeTitleQuote}[1]%
        {\hspace*{-\marginparsep minus \marginparwidth}%
         \begin{minipage}[t]{\textwidth}% \textwidth+\marginparwidth+\marginparsep
                {\large \bfseries #1}\\[-0.15\baselineskip]%
                 \rule{\columnwidth}{1pt}%
         \end{minipage}}
  • To add a running header:
\usepackage{fancyheadings}
\pagestyle{fancy}

%Width of line below running headers (0pt means no line)
%\setlength{\headrulewidth}{1pt}
%\renewcommand{\headrulewidth}{1pt}

\def\schoolName{School Name} % CHANGE: School Name
\lhead{Ricky J. Sethi}
%\chead{Ricky J. Sethi}
\rhead{Research Statement 2010}
%\rfoot{Cover Letter for \schoolName}

Lyx Usage Notes

  • Simple guide to all aspects of Lyx: http://www.stat.rice.edu/~helpdesk/howto/lyxguide.html
  • Used the amsalpha style in BibTex Bibliography dialog box
  • Can add multiple modules like theorem (which contains theorems, definitions, etc.) by selecting Document → Modules
  • If you get errors of Undefined Control Sequence for the EqRef macros, just go to Document → Settings → Latex Preamble and then add \usepackage{amsmath}
  • If you have trouble with references to algorithms, add \newcommand{\theHalgorithm}{\arabic{algorithm}} to the preamble, as per http://www.mail-archive.com/lyx-users@lists.lyx.org/msg10118.html
  • If you have trouble with table numbering where it skips a number, it ’s likely due to a long table and you need to add the following to the preamble:
      \let\myEnd\endlongtable
      \renewcommand\endlongtable{\myEnd\addtocounter{table}{-1}}
      
    as per http://texnik.dante.de/cgi-bin/mainFAQ.cgi?file=table/longtable#caption
  • If you have trouble with converting a .tex file to a .lyx file, try this from a cmd prompt:
      "c:\Program Files\LyX16\bin\tex2lyx.exe" -f infile.tex [outfile.lyx]
      
    This should show the errors (usually, it ’s just an unknown Document class so you need to add it to Miktex and create a layout for it first; if it gives an error on class not loaded/unable to load class, make sure the Input commands are all valid; e.g., ensure algorithm.inc is installed previously if you Input algorithm.inc).
  • Algorithm Package for Lyx: Used in Book Chapter on Gait: Get the algorithm package for Lyx from: http://bgu.chez-alice.fr/
    1. Copy algorithm.inc and article-algo.layout to C:\Program Files\LyX16\Resources\layouts
    2. Put the algolyx.sty in Latex by putting it in a new folder called algolyx in C:\Program Files\MiKTeX 2.7\tex\latex
    3. Next run MikTex ’s Settings and then Refresh FNDB
      1. Might also have to run Update Formats
    4. Then run Tools → Reconfigure in Lyx
    5. Finally, add the following to each .layout you ’re using like C:\Program Files\LyX16\Resources\layouts\IEEEtran.layout
          # Input lyx algorithm definitions
          Input algorithm.inc
          

UCR Thesis Templates in Lyx

Got the template from Kara; also available online at: http://www.math.ucr.edu/~jason/latextemplate/
  • Copy the following files to C:\Program Files\MiKTeX\tex\latex\ucr
    • sw20uctd.sty, thmsupp.tex, ucr.cls, uct10.clo, uct11.clo, uct12.clo
  • Next run MikTex ’s Settings and then Refresh FNDB
  • Create the following layout file, ucr.layout, in C:\Program Files\LyX16\Resources\layouts:
      #% Do not delete the line below; configure depends on this
      # \DeclareLaTeXClass[ucr]{article (ucr)}
      # Input general definitions
      Input stdclass.inc
       
      # Input lyx algorithm definitions (only if you've installed the algorithm package for Lyx from: http://bgu.chez-alice.fr/)
      Input algorithm.inc
      
  • Finally, run Tools → Reconfigure in Lyx
  • Next, Import the file uctest.tex into Lyx
    • Remove the Title and Author and, instead, add all the lines from \title to \maketitle into an ERT (a Tex Code box) since the \maketitle command Lyx inserts right after Title or Author causes a premature compilation error where it says \maketitle was not def ’ed; solution was as per here
    • Also, had to add \setlength\headsep{-0.5in} to the Latex Preamble in order to ensure the top margin isn ’t too large, as per: http://www.math.ucr.edu/~jason/latextemplate/
    • Also, had to change textheight to \textheight = 8.50in in the Latex Preamble from 8.25in
    • Had to comment out \newtheorem{algorithm}[theorem]{Algorithm} in the Latex Preamble, as well, in order to avoid errors when I include algorithms in the paper (since I add the algorithm style msyelf)
    • Finally, Kara wanted me to change to a darker font so I added \usepackage{palatino} to the Latex Preamble, as per http://www.image.ufl.edu/help/latex/fonts.shtml

Using Scientific Journal/Conference Templates in Lyx

  • BMVC: Adding/Using BMVC ’s .cls and .sty files:
    1. Put (as detailed below) bmvc2k.cls, bmvc2k_natbib.sty, and bmvc2k.bst in a new folder called bmvc2k in C:\Program Files\MiKTeX 2.7\tex\latex
    2. Create and add the bmvc2k layout in C:\Program Files\LyX16\Resources\layouts\bmvc2k.layout
        #% Do not delete the line below; configure depends on this
        # \DeclareLaTeXClass[bmvc2k]{article (bmvc2k)}
        # Input general definitions
        Input stdclass.inc
        
        # Input lyx algorithm definitions
        Input algorithm.inc
        
    3. Then run MikTex ’s Settings (and then Refresh FNDB) and then Tools → Reconfigure in Lyx
    4. Also, had to add subfigure.sty package from the ftp://ftp.fu-berlin.de/ repository since the original repository was giving an remote package repository is corrupted error
    5. Finally, had to comment out this line in bmvc2k.cls: \usepackage[sort,numbers]{bmvc2k_natbib} And, instead, used Document → Bibliography → Natbib (Numerical) in order to avoid the following error: Argument of \NAT@xcom has an extra }. which turns out to be a natbib error of some sort that Lyx creates (the original .tex works just fine)
      • Still used bmvc2k.bst as the style for the bibliography in Lyx
  • ACM Multimedia (ACMM): Adding/Using ACMM ’s .cls file:
    1. Put (as detailed below) sig-alternate.cls in a new folder called sig-alternate in C:\Program Files\MiKTeX 2.7\tex\latex
      • For the review version, I removed the \@copyrightspace from \maketitle in sig-alternate.cls to save space on the copyright block
      • If you want to cut the space between the title and text, change -12.75pc to -10.75pc in \advance\dimen0 by -12.75pc\relax % Increased space for title box – KBT
      • Can also change how low text extends by changing \textheight 666pt % 9 1/4 column height to \textheight 706pt % 9 1/4 column height
        • For CI Fellows, ended up making \advance\topmargin by -65pt % Leave 37pt above text for headers instead of \advance\topmargin by -37pt % Leave 37pt above text for headers and \textheight 733pt % 9 1/4 column height
    2. Create and add the sig-alternate layout in C:\Program Files\LyX16\Resources\layouts\sig-alternate.layout
        #% Do not delete the line below; configure depends on this
        # \DeclareLaTeXClass[sig-alternate]{article (sig-alternate)}
        # Input general definitions
        Input stdclass.inc
        
        # Input lyx algorithm definitions
        Input algorithm.inc
        
    3. Then run MikTex ’s Settings (and then Refresh FNDB) and then Tools → Reconfigure in Lyx
    4. ACM also requires the bib entries in the .tex file; here ’s a guide on how to do it in Lyx: http://wiki.lyx.org/Examples/AcmSigplan
      • Basically, export to .tex, then run latex name.tex, then bibtex name and then copy and paste contents of the .bbl into name.tex
    5. ACM also requires the bib entries in the .tex file; here ’s an automated script to do it: http://www.lyx.org/trac/ticket/4624
  • ACM CSCW: Adding/Using SIG CHI ’s .cls file:
    1. Put (as detailed below) chi2009.cls in a new folder called chi2009 in C:\Program Files\MiKTeX 2.7\tex\latex
    2. Create and add the chi2009 layout in C:\Program Files\LyX16\Resources\layouts\chi2009.layout
        #% Do not delete the line below; configure depends on this
        # \DeclareLaTeXClass[chi2009]{article (chi2009)}
        # Input general definitions
        Input stdclass.inc
        
        # Input lyx algorithm definitions
        Input algorithm.inc
        
    3. Then run MikTex ’s Settings (and then Refresh FNDB) and then Tools → Reconfigure in Lyx
    4. Ran into a problem with the bibliography definitions in the chi2009.cls file
      • As per here, when the references are just question marks, the problem is either the format setup in the .cls file or weird characters in the .bib file: http://www.latex-community.org/forum/viewtopic.php?f=4&t=3359
      • Replaced the bibliography sections in the chi2009.cls file (from
        %%% Actually, 'abbrev' works just fine as the default - Gerry
        to
        \gdef\balancecolumns
        )
        • Just went with bibliography Citation style Default (numerical) and first chose plain as style and then switched to abbrv as style
      • Replaced with the part it says (but had to remove the \newcommand\section part as it conflicted):
                  \setlength \labelsep {.5em}
                  \newcommand\newblock{\hskip
                       .11em\@plus.33em\@minus.07em} \let\@openbib@code\@empty
                  \newcommand\refname{References}
                  \newcommand\section{\@startsection
                        {section}{1}{\z@}%
                        {-3.5ex \@plus -1ex \@minus -.2ex}%
                        {2.3ex \@plus.2ex}%
                        {\normalfont\Large\bfseries}}
                  \newenvironment{thebibliography}[1]
                  {\section*{\refname}%
                    \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}%
                    \list{\@biblabel{\@arabic\c@enumiv}}%
                    {\settowidth\labelwidth{\@biblabel{#1}}%
                      \leftmargin\labelwidth \advance\leftmargin\labelsep \@openbib@code
                      \usecounter{enumiv}%
                      \let\p@enumiv\@empty \renewcommand\theenumiv{\@arabic\c@enumiv}}%
                    \sloppy \clubpenalty4000 \@clubpenalty \clubpenalty
                    \widowpenalty4000%
                    \sfcode`\.\@m} {\def\@noitemerr {\@latex@warning{Empty
                      `thebibliography' environment}}%
                      \endlist}
              
  • Springer/IJCV (ACCV also uses LNCS/llncs): For their Lecture Note Style ONLY, don ’t need this and can use the built-in LyX-provided documentclass article (Springer LNCS); otherwise, download from here
    • Copy the svglov3.clo and svjour3.cls files provided by Springer to C:\Program Files\MiKTeX\tex\latex\sv-journ3
    • Next run MikTex ’s Settings and then Refresh FNDB
    • Create the following layout file svjour3.layout in C:\Program Files\LyX16\Resources\layouts:
          #% Do not delete the line below; configure depends on this
          # \DeclareLaTeXClass[svjour3]{article (svjour3)}
          # Input general definitions
          Input stdclass.inc
          
    • Then, add the following to svjour3.layout:
          # Input lyx algorithm definitions
          Input algorithm.inc
          
    • Finally, run Tools → Reconfigure in Lyx
  • IEEE/tPAMI Journal: Follow directions in General Directions to Add Classes below
    • Did not need to do above for IEEEtran.cls as that was already in Lyx. All I had to do was load the shell ( bare_jrnl.tex) and then go to Document → Settings → Document Class and then add peerreview to Custom
  • NIPS Conference: Follow directions in General Directions to Add Styles below
    • Did this for NIPS conference: had to add a .sty for NIPS (it builds upon the article class).
    • Add everything before \begin{document} in the original .tex file to the Latex Preamble
      • Optionally, add \usepackage{nips07submit_e} to the Latex Preamble, too
    • In Lyx ’s Document → Settings → Document Class, make sure you use Article (algo) and not article as the base class as the former includes the Input algorithm.inc directive
  • CVPR: Adding/Using CVPR ’s .sty files and template:
    1. Put (as detailed below) cvpr.sty, cvpr_eso.sty, and eso-pic.sty in a new folder called cvpr in C:\Program Files\MiKTeX 2.7\tex\latex
    2. Next run MikTex ’s Settings and then Refresh FNDB
    3. Now you are able to include your package in the usual way: \usepackage{cvpr}, where you don ’t include the .sty in the file name in the \usepackage statement
      • For Lyx, when you import the egpaper_for_review.tex template, it adds the \usepackage{cvpr} and other lines into the Document → Settings → Latex Preamble
  • ECCV: Adding/Using ECCV ’s .cls and .sty files:
    1. Put (as detailed below) llncs.cls, lineno.sty, and splncs.bst in a new folder called llncs in C:\Program Files\MiKTeX 2.7\tex\latex
    2. Create and add the llncs layout in C:\Program Files\LyX16\Resources\layouts\llncs.layout
        #% Do not delete the line below; configure depends on this
        # \DeclareLaTeXClass[llncs]{article (llncs)}
        # Input general definitions
        Input stdclass.inc
        
        # Input lyx algorithm definitions
        Input algorithm.inc
        
    3. Then run MikTex ’s Settings (and then Refresh FNDB) and then Tools → Reconfigure in Lyx
    4. Add the following to the document ’s Preamble: Document → Settings → Latex Preamble
        \usepackage{lineno}\@ifundefined{definecolor}
        {\usepackage{color}}{}
        
      This will likely be added automatically when you import eccv2010submission.tex
    5. Finally, put everything between \begin{document} and \begin{abstract} into ERT at the top of the document and edit as needed.
      • Also, add \usepackage{times} in the Preamble to use the “Times, Helvetica, Courier ” defaults, if necessary
  • Cambridge University Press: Used in Book Chapter on Gait:
    • Create and add the cupbook layout in C:\Program Files\LyX16\Resources\layouts\cupbook.layout
      • Added in algorithm.inc, too (as long as it ’s already installed)
          #% Do not delete the line below; configure depends on this
          # \DeclareLaTeXClass[cupbook]{article (cupbook)}
          # Input general definitions
          Input stdclass.inc
          
          # Input lyx algorithm definitions
          Input algorithm.inc
          
    • Add cupbook‘s .cls and .sty files to Miktex ’s directory: C:\Program Files\MiKTeX 2.5\tex\latex\cupbook
    • Then run MikTex ’s Settings (and then Refresh FNDB) and then Tools → Reconfigure in Lyx
      • Specifically, add the .sty file to C:\Program Files\MiKTeX 2.5\tex\latex

General Directions to Add Classes

Reference: http://wastedmonkeys.com/2007/09/27/adding-a-new-class-in-lyx-windows
  1. Copy the xxx.cls file in ~\miktex###\tex\latex\ (where ### is the version (may or may not exist))
  2. Make a layout file matching the class file ( xxx.layout) like this (you may add extra settings), replacing xxx by your class name in the layout file:
      #% Do not delete the line below; configure depends on this
      # \DeclareLaTeXClass[xxx]{article (xxx)}
      # Input general definitions
      Input stdclass.inc
      
  3. Copy this file to the \Lyx###\Resources\layouts\
  4. Go to Start > Run ; type in cmd and press enter ; on the command prompt type texhash
  5. In LyX, do: Tools > Reconfigure ; Restart Lyx

General Directions to Add Styles

  1. Add the .sty to MikTex
    • Create a file for the information you ’d like to include in multiple files and name it something with a .sty extension, such as mylay.sty or mycommands.sty.
    • Put in the .sty file all the commands you ’d like to use in multiple source files and save the file.
    • You have two options for where to save the file to be able to include it in LaTeX source files:
      1. (Recommended) Install the .sty file with MiKTeX as follows:
        • Navigate to the folder where LaTeX packages get installed. If you accepted the default location when you installed MiKTeX, this folder is probably C:\Program Files\MiKTeX 2.5\tex\latex
        • Create a new folder inside this folder and call it whatever you want.
        • Save your .sty file into this folder.
        • Open the MiKTeX Settings (old: Options) program. (You can do this by clicking Start → All Programs → MiKTeX → MiKTeX Settings)
        • Click Refresh FNDB on the window that opens. Now you should be able to use any information in that .sty file in any LaTeX source file.
      2. Simply put your .sty file in the same folder as your source files. Unfortunately, this means if you have LaTeX source files in other folders, you ’ll have to carry copies of your .sty files to those folders, too. The real problem with this approach comes when you want to change one of these files, you have to change all those copies.
    • Now you are able to include your package in the usual way: \usepackage{your file name}, where you don ’t include the .sty in the file name in the \usepackage statement.
    • You can now call any command you have created in your .sty file.
  2. Add the .sty to Lyx
    • Go to: C:\Program Files\LyX16\Resources\layouts
    • For the sake of example well assume that the style file is called myclass.sty and it is meant to be used with report.cls which is a standard class.
      cp report.layout myclass.layout
    • Then edit myclass.layout and change the line: \DeclareLaTeXClass{report} to read \DeclareLaTeXClass[report, myclass.sty]{report (myclass)}
    • Then add the following near the top of the file:
          Preamble
             \usepackage{myclass}
          EndPreamble
          
    • Finally, Run Tools → Reconfigure in Lyx
  3. Edit the Document ’s Preamble

Không có nhận xét nào:

Đăng nhận xét