View on GitHub

Latex Code Examples for Papers

Latex code examples (reference, equations, tikz, etc.) for research papers

Star Fork Star DOI

This is a work-in-progress website of support files for writing various files with latex, produced by Fan. The project includes sample file for papers, exams, homeworks, etc.

This package is synced with overleaf project, all latex files and examples here are viewable and compilable on the overleaf project synced site.

From other repositories: For code examples, see Python Example Code, R Example Code, Matlab Example Code, and Stata Example Code. See here for all of Fan’s public repositories.

Materials gathered from various projects in which latex is used. The goal of this repository is to make it easier to find/re-use latex files produced for various projects.

1. Latex Equations, Symbols, etc.

1.1 Equations

  1. Multiple Lines: tex | pdf
    • split vs gathered
    • substack vs array
  2. Equation Cases: tex | pdf
    • cases

1.2 Symbols, Operators and Accents

  1. Symbols and Accents: tex | pdf
    • underline vs overline, underaccent bar vs bar
    • boldsymbol vs mathbf
  2. Unicode Handling: tex | pdf
    • Declare unicode and use unicode directly in latex
    • inputenc, DeclareUnicodeCharacter

2. Latex References, Spacing, etc

2.1 References

  1. Biblatex Citation and Bibliography: tex | pdf
    • biblatex-chicago; \textcite{becker_human_1986}; \autocite{becker_human_1986}
    • Full title in-text citation: \citetitle{becker_human_1994} \autocite{becker_human_1994}
    • Display URL in bibliography if DOI does not exist with biber backend
    • Biblatex format for for working papers mimeo and in series
  2. Section References, Vary Link Colors by Section: tex | pdf
    • Section \ref{sec:intro} (Page \pageref{sec:intro}); \hypersetup{hidelinks=true}

2.2 Spacing and Sizing

  1. Reduce Line-Gap: tex | pdf
  1. Repaginate Response for Referees: tex | pdf

3. Latex Tables

3.1 Multiple-Panel Estimation Table

  1. Multi-Panel Estimation Table Medium Size: tex | pdf
    • Three main variables, three interactions, three controls, presented in separate groups
    • Two groups of estimates, results from four regressions
    • Table caption and multi-line table notes with linebreaks
  2. Multi-Panel Estimation Table Large Size: tex | pdf
  3. Small Estimates Table: tex | pdf

3.2 Text Table

  1. Tables with Text Only: tex | pdf
    • Table with color-shading, padding, and thicker borders, with text inside
    • Landscape table with multiple columns and multiple heading rows
    • Wrapped text with multirow and multicolumn

4. Latex Figures

4.1 Figure Alignment Figures

  1. Figure Alignment: tex | pdf
    • Center align single or multiple sub-figures with captions, vertically and horizontally
    • Caption equal-width with subfigure
    • latex: float, subcaption, caption

5. Latex Tikz

5.1 TIKZ Basics

  1. Tikz Page Layout: tex | pdf
    • Relative positioning, proportional to textwidth
    • Two or four subfigures
  2. Tikz Figure Annotation: tex | pdf
    • point to intercept and slope

5.2 Timeline with TIKZ

  1. Tikz Timeline: tex | pdf
    • Straight and curved connected lines
  2. Tikz Dynamically Sized Eight Pane Model Timeline: tex | pdf
    • Dynamically sized panes for prior, current and next periods
    • Dynamically sized ext panes, graph panes and labeling areas
    • Parametrized proportioning of panes with dynamic adjustments

5.3 Equation Graphing with TIKZ

  1. Tikz Linear Spline Equation Plotting: tex | pdf
    • sum of linear equations
    • linear spline and inverted linear spline
    • def, domain, variable, plot

5.4 Diagrams with TIKZ

  1. Tikz Game Strategy Graphs: tex | pdf
    • continuous and discrete strategies
    • strategy branches, curved and straight lines
  2. Tikz Node-based Diagrams: tex | pdf
    • Diagrams with line-connected and text-filled circles and rectangles
    • Diagrams with equations, colored shapes, multiple connects rows and columns of shapes

6. Latex MISC.

6.1 Conversion

  1. Pandoc File Conversion: tex | pdf

7. Templates

In overleaf, click on New Project, choose upload project, then select zip below.

7.1 Working Paper Templates

  1. Template Figure Table and Reference: tex | pdf | zip

7.2 Revise and Resubmit Templates

  1. Template Paper, Response to Referees, Section Numbering and Bib: tex | pdf | zip
    • Figures, tables, references.
    • Separate page numbers for each section: \renewcommand{\thesection}{\arabic{section}}
    • Separate heading count for responses to referees: \setcounter{section}{0}
    • Separate bibliographies: refsection

7.3 Joint Working and Accepted Paper Templates

  1. Working Preprint and Accepted Paper Submission to Journal: journal-tex | journal-pdf | preprint-tex | preprint-pdf | zip
    • journal-pdf and journal-tex: All paper contents in a single PDF for submission to journal, with separate references and page numbering for the main text and the appendix, respectively. Contents are organized for copy-editors to find easily.
    • preprint-pdf and preprint-tex: All paper contents in a single PDF with one page-numbering for main and appendix and a single set of references. This file uses the same input files and saved strings as the journal-tex file. The resulting PDF can be shared as a preprint.

7.4 Other Templates

  1. Template Image Only Appendix: tex | pdf | zip
    • An appendix file with only figures.
    • Page number, section number, and alignment control for multiple figures.
    • Captions below and above figure. Captions with heading and sub-notes.
  2. Template Figure Table and Reference Roman 12 Double Space: tex | pdf | zip
  3. Template Recommendation Letter: tex | pdf | zip
    • Recommendation letter with logo and signature.
    • Contact and address panel.

7.5 Github Integration

This overleaf project is synced with this git repository. You can clone the project, pull project to overleaf, and compile in overleaf browser. Specifically: clone the repo; go to your overleaf account and create a project; click on menu under sync with git/github.

The writing/structure is to:

  1. Store latex formatting file etc in separate files away from paper tex.
  2. For papers, write in tex fragments stored in separate files. Main tex paper file mainly contains structure/outline.
  3. Files synced through git/github, pull from github to edit/share with co-authors on overleaf.com or edit locally.

Please contact FanWangEcon for issues or problems.

8. Program Installations

  1. Install Python, R, Latex, VSCode, Atom etc: Rmd | pdf | html
    • Conda base Python, R in and outside of Conda
    • Windows and Linux instructions
    • Install various editors: VSCode, Atom, etc.
    • conda update –all
    • Rtools, install.packages(), devtools::install_github()
  2. Atom, Git, Github, etc Set-up for Linux: Rmd | pdf | html
    • sudo apt-get install atom; install git
    • git init; config; git remote add; git pull
    • wget; bash; source
    • ssh-keygen -t rsa; cat
  3. Vim and Neovim Set-up: Rmd | pdf | html
    • vimrc file, Vim-Plug plugin setup
    • Plug ‘vim-airline/vim-airline’
    • vim-airline, onedkar, Goyo, Limelight

9. gitpages and git

  1. Bash Pull and Push from Single Remote Github Repo: Rmd | pdf | html
    • Create a new local folder after checking directories
    • Pull from remote after prompting for password
    • Sample bash file
  2. Multiple git Repositories setup with Github: Rmd | pdf | html
    • set up ssh rsa security with github
    • initalize multiple repositories
    • secure ssh session to avoid passphrase entry
    • mkdir d1 d2; git config –global; git init; git remote add
    • eval “$(ssh-agent)”; ssh-add ~/.ssh/id_rsa
    • git pull github master; git pull -u github master
  3. Basic Git Commands: Rmd | pdf | html
    • Git check file status
  4. Sample Githug page: md | html
    • Conda base Python, and Conda environment for R
    • conda update –all
    • Rtools, install.packages(), devtools::install_github()
  5. Git Subtree: Rmd | pdf | html
    • dropbox folder as main project git
    • subfolder also as git subtree synced to overleaf
    • git: git subtree add, push, pull

10 reveal.js

10.1 reveal.js Basic Examples

  1. Go to the latest reveal.js release
    • go to the end of the latest release’s release info, look for zip file and download
    • just open the zipped folder, the index.html is already working.
  2. To allow multiple files to share the same css, js, lib, and plugin, create a folder to put these folders from the zipped file.
    • in a present folder that is parallel to the css, js, and other folders, put in there testing and other html files.
    • replace links to css, js, lib and plugin in the testing files

10.2 Default Tests

  1. Default Testing File
  2. Default Demo File
  3. Modified Math Presentation

10.3 Rmd and revealjs

  1. Revealjs Rmd and PDF: Rmd | pdf | html
    • R for revealjs, include pictures
    • convert to PDF using decktape
    • git: git subtree add, push, pull
  2. Revealjs Rmd, Tex and PDF: Rmd | pdf | html
    • R for revealjs, include equations, newcommands
    • Include child tex files that define a set of newcommands
    • convert to PDF using decktape
    • git: git subtree add, push, pull

Please contact for issues or problems.

DOI

RepoSize CodeSize Language Release License