Handy software for a researcher
Mendeley, Zotero
Evernote, OneNote
IrfanView
pdfsam
7-zip
TeamViewer
For first year economics PhD students
“Programming Languages and Protocols” on this website: http://byumcl.bitbucket.org/bootcamp2013/economics/intro.html.
Matlab Boot Camp: http://people.brandeis.edu/~pmherb/MatlabBootCamp/.
Beginner Intro to TeX/LaTeX/LyX – How to set it up in Windows 7/8.1
One way to easily install LaTeX and the editor LyX in Windows:
- Install MiKTeX. Run the update wizard to get the latest updates.
- Add your favorite document classes (e.g., Elsevier journal articles) to the path C:\Users\AppData\Roaming\MiKTeX\2.9\tex. [AppData does not appear in my pc because it’s hidden. Check by launching Windows Explorer then click on the View menu on the ribbon, now tick ‘Hidden items’.].
- Rehash by running texhash, or /miktex/bin/texhash.exe (on Windows this may be in C:\Programs).
- Install LyX. Click Tools > Reconfigure, and restart it.
convert latex to rtf (doc, odt)
Download latex2rtf: http://latex2rtf.sourceforge.net/
1. run LaTex first to get .aux file
2. run latex2rtf to get rtf and open it in Word
Note:
Many templates’ commands cannot be recognized. latex2rtf default set: \documentclass{article}. Delete \begin{article} and \end{article} in the template if there is errors during compiling.
Insert matlab code into LaTex
- Download “M-code LaTeX Package” from Mathworks webpage
- Copy mcode.style to the folder C:\Program Files\MiKTeX 2.9\tex\latex\xcolor.
- Add the following in the preamble:\usepackage{listings}
\usepackage{xcolor}
\usepackage{textcomp}
\usepackage[numbered,framed]{mcode}
In LyX, insert a TeX code box.
Insert m-code inline: \mcode{for i=1:3, disp(‘cool’); end;}
Insert m-code blocks: (% it’s a mess when copy and paste. prefer the 3rd approach)
\begin{lstlisting}
% Plot expected state and policy path
a = [a; c(:)’];
r = a’;
\end{lstlisting}
Insert a m-code file:
\lstinputlisting[firstline=110, lastline=117]{/weed.m}
Break long formulas in a cell of “cases environment”
\begin{split}
…..\\
….
\end{split}
Insert the formula between the two commands. Wherever you want to break the line, insert ‘\\’ (without the quotes)
dvipdfm vs. ps2pdf vs. pdflatex
If a figure is pdf file, use psflatex (zooming does not affect the figure quality)
If a figure is eps file, any compiling route works.
Adding .cls file to Lyx in Windows 7
Reference: http://www.paulkiddie.com
This assumes version 2.9 of Miktex and version 2.0 of Lyx. If you are using an earlier or later versions, replace with the correct version numbers where I’ve used them.
- Get a copy of the class file, and copy it into a folder with the same name into
C:\Users\\AppData\Roaming\MiKTeX\2.8\tex
. So, foreethesis.cls
, you should have a folder calledeethesis
withinC:\Users\\AppData\Roaming\MiKTeX\2.8\tex
. [AppData does not appear in my pc… Search for “AppData” and find the folder]- Create a new file and paste the following into it:
#% Do not delete the line below; configure depends on this # \DeclareLaTeXClass[xxx]{article (xxx)} # Input general definitions Input stdclass.increplacing
xxx
with the class name (without the .cls extension). In my case,xxx
iseethesis
, and the code above becomes:#% Do not delete the line below; configure depends on this # \DeclareLaTeXClass[eethesis]{article (eethesis)} # Input general definitions Input stdclass.incThanks goes out to http://wastedmonkeys.com/2007/09/27/adding-a-new-class-in-lyx-windows for this.
- Save this file to
C:\Program Files\LyX16\Resources\layouts
, naming iteethesis.layout
.- In a command prompt (type
cmd
in start menu), typetexhash
. What you will now see it doing is iterating through several folders for new classes, one of which (C:\Users\AppData\Roaming\MiKTeX\2.8\
) is where we copied theeethesis.cls
class file into.- Within Lyx, hit Tools > Reconfigure, then restart Lyx.
- Open a document and click Document > Settings. Click on ‘Document Class’, expand the drop down menu and you should see ‘
article (xxx)
’ is visible, and usable, (like below) within the drop down menu.
UCR Thesis Templates in Lyx
1) Copy and paste these into the Preamble
default page size – letter: 8.5in [1.5+6+1]*11in [1.5+8.5+1]
\textwidth = 6.00in
\textheight = 8.50in
\topmargin = 0.75in
2) I get an error when using \thebibliography: \newblock undefined.
Check the following in ucr.cls
. Move it to the beginning of the bibliography section.
\def\newblock{\hskip .11em plus .33em minus .07em}
3)I got a LaTeX Error when using \subfig: No counter ‘subfigure@save’ defined.
Delete \usepackage{subfigure} in the Preamble
4) Bibliography/Table/Figure Caption is double-spacing
Add ssp and dsp ( into a Tex Code box) before and after the BibTex Generated Bib box. Note that ssp and dsp have been defined in ucr.cls
.
\ssp
BibTex Generated Bib
\dsp
5) Generate bookmarks in the PDF file
Document→Settings→PDF properties: check the boxes under Hyperlinks and Bookmarks dialog
6) Bibliography and Appendix do not appear in the table of contents (TOC)
use the package tocbibind from CTAN, i.e. add \usepackage{tocbibind} to the Preamble
7) Add additional entries to TOC
The following LaTeX command: \addcontentsline{toc}{chapter}{APPENDIX} will add ‘APPENDIX’ to TOC and refer to the page where you have inserted this command. So this line should be added as ERT to the “page” of the document that you want to appear listed in the table of contents. This can also be used to include unnumbered sections to the TOC. Just insert the line immediately below the section header.
8) Table/Figure caption left-justified and bold
add \usepackage[nooneline, font={bf}]{caption} to the Preamble
9) Footnote spacing
space between footnotes: \setlength{\footnotesep}{2mm}
space between the text body and the footnotes: \setlength{\skip\footins}{1cm}
10) How to stop equation auto numbering in TeX code?
\begin{equation*} … \end{equation*}
11) How to modify Tex code from Mathematica so that it fits the thesis document class?
copy and paste into Notepad, replace \begin{doublespace} and \pmb with blank, replace \end{doublespace} with \par\vspace{5mm}. Break long lines in Mathematica before generating Tex code. In Mathematica, do not write comments in equations.
reading this link for inserting child document: http://stackoverflow.com/questions/5310409/how-to-add-a-large-code-appendix-in-latex-lyx
Method I use: save the code in a plain text file. create a Tex code box, Insert –> file –> Plain Text…
[http://www.sethi.org/utils/mynotes/public_notes/latex_notes]
Got the template from Kara; also available online at: http://www.math.ucr.edu/~jason/latextemplate/
Copy the following files toC:\Program Files\MiKTeX\tex\latex\ucr
sw20uctd.sty
,thmsupp.tex
,ucr.cls
,uct10.clo
,uct11.clo
,uct12.clo
Next run MikTex ’sSettings
and thenRefresh FNDB
Create the following layout file,ucr.layout
, inC:\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, runTools → Reconfigure
in Lyx Next,Import
the fileuctest.tex
into Lyx
Remove theTitle
andAuthor
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 theLatex 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 theLatex Preamble
from8.25in
Had to comment out\newtheorem{algorithm}[theorem]{Algorithm}
in theLatex 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 theLatex Preamble
, as per http://www.image.ufl.edu/help/latex/fonts.shtml
Instead, to change fonts, check here: http://stackoverflow.com/questions/877597/how-do-you-change-the-document-font-in-latex
Export all charts from a Calc spreadsheet to EPS_Macro
Calc spreadsheet: Tool -> Macro -> Organize Dialogues… -> New -> copy and paste the macro you have
Code
Sub Main
Dim oDoc, oDocCtrl, oDocFrame, oDispatchHelper
oDoc = ThisComponent
oDocCtrl = oDoc.getCurrentController()
oDocFrame = oDocCtrl.getFrame()
oDispatchHelper = createUnoService( “com.sun.star.frame.DispatchHelper” )
Dim storeUrl
storeUrl = oDoc.getURL()
storeUrl = Left( storeUrl, Len( storeUrl ) – 4 )
nCharts = 0
‘ Search the draw page for the chart.
Dim oSheets, oSheet, oDrawPage, oShape
oSheets = oDoc.getSheets()
For i = 0 to oSheets.getCount() – 1
oSheet = oSheets.getByIndex( i )
oDrawPage = oSheet.getDrawPage()
For j = 0 to oDrawPage.getCount() – 1
oShape = oDrawPage.getByIndex( j )
‘ Can’t call supportsService unless the com.sun.star.lang.XServiceInfo is present.
If HasUnoInterfaces( oShape, “com.sun.star.lang.XServiceInfo” ) Then
If oShape.supportsService( “com.sun.star.drawing.OLE2Shape” ) Then
‘ Is it a Chart?
If oShape.CLSID = “12DCAE26-281F-416F-a234-c3086127382e” Then
‘ Select the chart shape.
oDocCtrl.select( oShape )
oDispatchHelper.executeDispatch( oDocFrame, “.uno:Copy”, “”, 0, Array() )
‘ export the chart
nCharts = nCharts + 1
ExportSelection( storeUrl + “_chart” + nCharts + “.eps”, “image/x-eps” )
EndIf
EndIf
EndIf
Next
Next
End Sub
Sub ExportSelection(url As String, mediaType As String)
‘ Create a new Draw document
Dim aArgs(1) As New com.sun.star.beans.PropertyValue
aArgs(0).Name = “Hidden”
aArgs(0).Value = True
oDrawDoc = StarDesktop.loadComponentFromURL( “private:factory/sdraw”, “_blank”, 0, aArgs() )
‘ Past current selection
Dim oDrawDocCtrl, oDrawDocFrame, oDispatchHelper
oDrawDocCtrl = oDrawDoc.getCurrentController()
oDrawDocFrame = oDrawDocCtrl.getFrame()
oDispatchHelper = createUnoService( “com.sun.star.frame.DispatchHelper” )
oDispatchHelper.executeDispatch( oDrawDocFrame, “.uno:Paste”, “”, 0, Array() )
‘ Get an export filter object
Dim exportFilter
exportFilter = createUnoService( “com.sun.star.drawing.GraphicExportFilter” )
‘ get first draw page
Dim oDrawPages, oDrawPage, oShape
oDrawPages = oDrawDoc.getDrawPages()
oDrawPage = oDrawPages.getByIndex( 0 )
oShape = oDrawPage.getByIndex( 0 )
exportFilter.setSourceDocument( oShape )
‘ Set the filter data
Dim aFilterData(5) As New com.sun.star.beans.PropertyValue
aFilterData(0).Name = “Level” ‘1=PS level 1, 2=PS level 2
aFilterData(0).Value = 2
aFilterData(1).Name = “ColorFormat” ‘1=color, 2=grayscale
aFilterData(1).Value = 1
aFilterData(2).Name = “TextMode” ‘0=glyph outlines, 1=no glyph outlines, see ooo bug 7918
aFilterData(2).Value = 1
aFilterData(3).Name = “Preview” ‘0=none, 1=TIFF, 2=EPSI, 3=TIFF+EPSI
aFilterData(3).Value = 0
aFilterData(4).Name = “CompressionMode” ‘1=LZW, 2=none
aFilterData(4).Value = 2
Dim aProps(2) As New com.sun.star.beans.PropertyValue
aProps(0).Name = “MediaType”
aProps(0).Value = mediaType
aProps(1).Name = “URL”
aProps(1).Value = url
aProps(2).Name = “FilterData”
aProps(2).Value = aFilterData()
exportFilter.filter( aProps() )
End Sub
/**************************************************************************
*
* Copyright 2007 Jose Fonseca
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* “Software”), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
**************************************************************************/
Add space between the lines in multiline formulas
In LATEX additional line space is specified as optional argument of the new line command. This is not yet possible in LYX33, therefore the whole formula must be inserted in TEX-mode. To add in our example space, the command \\[3mm] is inserted at the end of the first line.
1. select the part you’re interested, View -> View Source, copy the TeX code
2. go to .lyx, Insert -> Tex code (Ctrl+L), paste the code into the redbox, and add \\[3mm] at the end of the first line
To set the line separation for all lines in a formula, the length \jot is changed.
1. load the LATEX-package calc in LATEX-preamble with the line
\usepackage{calc}
2. insert the command
\setlength{\jot}{3mm+3pt}
in TEX-mode before the formula
Break long formulas in a parenthesis in LyX
Lyx has an “Insert -> Math -> AMS multiline environment” control, but does not work in the middle of a parenthesis.
How to break lines in the middle of a parenthesis?
In AMS multiline environment,
\left[… \right.
(line break here) \left. … \right]
Do not use Alt+M to get a parenthesis. Follow the way above. Close with ‘\right.’ before line-break and reopen with ‘\left.’
\left[…\left[… \right.\right.
(line break here) \left.\left. … \right] … \right]
This can lead to parentheses of different size. Size them yourself using ‘\big(‘, ‘\Big(‘, ‘\Bigg(‘, etc. or use \vphantom.