Skip to content

Setbeamertemplate Bibliography Item Analysis


Basic LaTeX Lesson I

Why Latex

  • What you see is what you mean (WYSIWYM)
  • No need to bother with formatting, LaTex will do it for you
  • Standard for academic publishing
  • Easy to include math/graphics/tables

Installation

Windows -> Install MikTeX

Mac -> Install MacTex

Windows

For Windows, go to http://miktex.org/. You will then see the following at the top of the page.


Clicking the download button will then bring you to this page.


Download MiKTex, then install and open TexWork. You are then ready to use LaTex on your Windows computer.

 Mac

For Mac users, head to http://tug.org/mactex/. Click on the download MacTex button, as shown below.


Run the installation program, and you are ready to use LaTex on your Mac.

Online: Overleafs

For users who do not wish to install any programs, LaTex can also be used online. This also makes it easy for multiple people to edit the same file at the same time, similar to Google Docs. Simply go to https://www.overleaf.com/ and create a free account, and you’re ready to use LaTex online. In the rest of this user guide, I will show examples using the online version.

To create a new project, simply click on the button on the left-hand side of the screen. 


You will then see the following layouts. In most cases, choosing a blank page as your layout is enough.

Hello World!

We then begin by showing you how to type text in the document. On the right-hand side, you will notice that there is a preview, which updates after a few seconds every time you make a change in the left-hand side.


Here, we have typed the words “Hello World!” between the \begin{document} and \end{document}. Whatever text, pictures, or tables is included in between the 2 commands will appear on the document itself, and you can see this on the right-hand side.


Indents, spacing, font size, font type, color etc can all be changed using certain commands.

Front Matter

Next, we will show you how to include a title in the document.


Here, we include a title, today’s date, and an author. The {\today} command tells LaTex to use today’s date, otherwise, you can simply enter a specific date if you prefer. After including the 3 items, we must then include a \maketitle command at the end, otherwise the title will not be created.


Sections

Next, we move on to sections and subsections. This is important if you wish to divide your text into nice, separate sections for readability.


As seen above, I include empty lines in between each section. While this is not necessary, as LaTex does not do anything when you include empty lines, it is easier for people who want to edit your code in the future, or even yourself. Including empty lines between each portion of code is a useful thing, especially when you have very long codes.

When you include sections by using \section{}, LaTex automatically numbers each section for you. You might have seen this in academic papers, this is why people use LaTex when writing their papers. Subsections will take on that particular section’s number, and then include a second number behind to indicate that it is a subsection. We use \subsection{} here. You can also use \subsubsection{} if you wish.


Reference

For referencing, we then show you how to do citations in LaTex, and also how to include a bibliography.


The \cite{} command will automatically extract information from the bibliography. To create a bibliography, use the \begin{thebibliography} and \end{thebibliography} commands. Without creating the bibliography, the citations will simply show a question mark “?”. To create items in the bibliography, we use \bibitem{}, where the name in the brackets is what you use when using \cite{}. The references and citations are automatically numbered by LaTex.

The argument to \begin{thebibliography} is used for setting the hanging indentation of the bibliography items. If you use numeric labels, then the argument should be a single digit (9 is commonly used) if there are less than ten items; two digits (commonly 99) if there are from 10 to 99 items and so on. If you use symbolic labels (say Xyz12 or XY13) like BibTeX creates with the abbrv style, then you should pass the widest label, for instance \begin{thebibliography}{Xyz12} or whatever abbreviation is the widest. The correct argument is needed in order to make the labels flush left and the bibliography items to have the precise hanging indentation.


Appendix

Lastly, we show how to create an appendix. Simply type \appendix and LaTex will label that section as an appendix for you, using the letter A.


Source Code

To refer to the read-only version of the source code, head to https://www.overleaf.com/read/fpvwmvjpgfgs. 

Basic LaTeX Lesson II

Fonts


As shown above, we can change the font size used throughout the paper by changing the number here. In this example, font size is 12, and we can change it by just typing another number to replace the “12”.

Here, we show the \Huge, \textit{}, \tiny, \large, \textbf{}, and \footnote{} commands.


As seen from the image above, \Huge makes the text size really huge. Another alternative is \large, which also enlarges the font but to a smaller extent. You can also use \tiny to make the font smaller. \textit{} shows the words inside the brackets as italics, and \textbf{} shows them in bold (bf is short form for boldface). Using the \footnote{} command creates a footnote at the bottom of the page.


We use the soul package, which allows us to use features such as highlight \hl{}. The result is the text with underlines.


We can also change the color of the font, by using the color package.


The color that is entered in the {} will be used, in this example it is red.

Page layout

We have a few commands to edit the page layout. Using \\ at any point creates a break in the line, and LaTex registers it as an empty line. This is useful when you want to create empty line spacing in your text. \newpage creates a new page at that point, so any content after the command is automatically in put in the next page. \noindent suppresses paragraph indentation when used at the beginning of a paragraph. If used in the middle of a paragraph, it is ignored and does not suppress the paragraph indentation. \vspace{insert number} refers to vertical spacing, or the spacing between lines. The number entered should either be in cm, or inches (type as in). We can also use \hspace{} for horizontal spacing between words.


The geometry package allows you to change the margins of the page, if you wish to. To change the individual sides’ margins, simply use \geometry{left=2.5in, right=2.5in, top=2.5in, bottom=2.5in}.

The setspace package allows you to edit the line spacing between each line, similar to Word’s function. Options include \singlespacing, \onehalfspacing, \doublespacing. Take note that this should be put before the \begin{document} command.

Lists


Using \begin{itemize} and \end{itemize} allows us to include sentences as items, by using \item. These items will then appear as bulleted points, as shown below.


Likewise, the \begin{enumerate} and \end{enumerate} also works the same way, and we also use \item to create items. The only difference is that enumerate uses numbers, and itemize uses bullet points.


Math


Using the $ signs tells LaTex that we are trying to enter Math, instead of just text. We can also include symbols by using \symbolname, for example \alpha, \beta etc. \frac{}{} creates fractions, and \[ insert equation here \] creates an equation. For a complete list of symbols, fonts, and mathematical functions, refer to https://en.wikipedia.org/wiki/Wikipedia:LaTeX_symbols.


Tables


Tables are created using the \begin{tabular}{} and \end{tabular} format. We can specify what type of table we want, and LaTex will create it for us.

Input Meaning
 l     left-justified column
 c  centered column
 r  right-justified column
 p{'width'}   paragraph column with text vertically aligned at the top
 m{'width'}  paragraph column with text vertically aligned in the middle (requires array package)
 b{'width'}  paragraph column with text vertically aligned at the bottom (requires array package)
 |    vertical line
 ||  double vertical line

In the example above, we have used “l c r”, so LaTex creates a table with 3 columns, with the corresponding directional justifications. The result is then shown below.


Graphics

To include graphics in the document, we need to make use of the graphicx package, which is done by using \usepackage{graphicx}.


We can then begin inserting the picture by using \begin{figure}. There are a few options we can add on, shown below.

Optional parameters to fine tune the placement of tables and figures, with the following meaning:

 h here
 t top
 b bottom
 p page of float

and LaTeX will try to honour the placement with respect to the actual place, the top or bottom of the page, or a separate page of floats coming immediately after the present insertion point. For example, when using ht LaTeX will try to put the figure at the insertion point, then on the top of the next page if it happens to violate its typesetting rules. You may also force LaTeX to "insist" on these specifications by adding an exclamation mark (!) before the placement parameters, e.g. \begin{figure}[!htb].

We can also include a caption, center the picture, and lastly we have to tell LaTex which picture we wish to include.

Source code

The reference code can be found at https://www.overleaf.com/read/swfvjwxznbsh. 


FAQ

Basics

How to write Hello World?


How to move the title above?

Math

How to allow Math equation to break across pages?

How to write an expression with cases?

How to showing labels in pdf?

How to adding Section Number to Equations?

How to adding reference section to the bookmark?

Method 1:


Method 2:

Page Layout

How to start a new line?

How to start a new page?

How to change the size of margin?

How to change line spacing?

How to make no indentation? 

How to fill a horizontal line?

Beamer

How to add section page manually?

Method 1: Default section pageMethod 2: 

How to add section page without section number?

How to add Table of Content (TOC)?

How to make TOC for each Section with Current Section Highlight?

How to make TOC for each Section with Current Subsection Highlight, Hiding other subsections not in the same section

How to remove the default navigation bar at the bottom right-hand corner?

How to add frame Number on right bottom corner?

How to change margin of a slide?

How to autofit the content into slide?


How to make the slide to stop using \pause?

How to change the order of appearance?

References

What is the standard format for BibTeX file?

How to create reference format following economics journals?








Using Latex for CV

Latex is a very convenient tool to write CV. 

How to write CV for Industry Jobs in LaTeX?

Here are the pdf and tex files:  [PDF File] and [LaTeX File]

How to write a CV for academic jobs in LaTeX

Here are the pdf and tex files:  [PDF File] and [LaTeX File]

Tikz

How to define variable for calculation of Tikz Package


Texstudio

How to write a macro to red-color text?





Microsoft Word

How to convert from LaTeX to DOCX using Pandoc?

Topic revision: r25 - 03 Jun 2012, FrankHarrell

Template for Presentations and Handouts using LaTeX, Beamer, and a PDF Viewer

Example PDF Output

Instructions

Store your file in and run to produce pdf after setting the variable to zero (slides) or one (handouts). You will also have to run if you have references in the talk. If using contributed LaTeX styles such as (a highly recommended one) you may have to install such styles before running . See GetLatex for a script for fetching and installing styles from the internet. Note that if you have references, you will get a warning about a when running . Enter followed by to ignore these warnings, or define using the definition appearing later. If you are running Kubuntu/Ubuntu/debian, you may install Beamer with the following if your system does not already have it: sudo apt-get update sudo apt-get install latex-beamer pgf (texlive-latex-recommended) See BeamerTips for a different method of creating separate slide and handout files. There are many themes available for Beamer. Most if not all of them are displayed at http://mike.polycat.net/gallery/beamer-themes You can also find a short course about Beamer at http://gobics.de/katharina/beamer-script.pdf Download the Biostatistics logo into a central directory in your home area, such as and set a symbolic link to it, e.g., run the command . Instead you can change the command below to reference a file such as . If you need to put R code or a verbatim text in your presentation, see this.

Template

\def\handout{0} % set to 1 to produce 4-up handouts instead of slides \def\notes{0} % set to 1 to show \note{}s \ifnum\handout=1 % see above for an alternative which uses two preamble files \documentclass[handout,13pt,compress,c]{beamer} \usepackage{pgfpages} \pgfpagesuselayout{4 on 1}[letterpaper,landscape,border shrink=4mm] % or: \pgfpagesuselayout{2 on 1}[letterpaper,border shrink=4mm] \setbeamertemplate{footline}[page number] % omit if don't want slide number at bottom right % use \setbeamertemplate{footline}[text line]{xxxx} if you want xxxx at bottom left of each slide % use \setbeamertemplate{footline}[text line]{xxxx\hfill\thepage} % if you want xxxx at bottom left, page # at bottom right \else \documentclass[13pt,compress,c]{beamer} \fi \usetheme{PaloAlto} % Also try Warsaw, Malmoe, Madrid, Berlin, Darmstadt; see % /usr/share/texmf/tex/latex/beamer/themes/theme and the above gallery. % PaloAlto has section and subsection titles in left panel with highlighting % Darnstadt shows section names at top with progress bubbles % Optional: \usefonttheme{serif} % Another nice theme courtesy of David Airey: % \usetheme[secheader]{Boadilla} % \definecolor{mygold}{rgb}{0.85, 0.60, 0.00} % \usecolortheme[named=mygold]{structure} % \setbeamercovered{dynamic} \usepackage{graphicx} \usepackage{natbib} % for author year citations \citet \citep \usepackage{relsize} % for \smaller etc. \DeclareGraphicsExtensions{.pdf, .jpg, .png} \setbeamercolor{normal text}{bg=blue!5} %\setbeamertemplate{headline}[infolines theme] %\setbeamercolor{title}{fg=black!80!black,bg=blue!20!white} \ifnum\notes=1 \setbeameroption{show notes} \fi \newcommand{\ft}[1]{\frametitle{#1}} \newcommand{\bi}{\begin{itemize}} \newcommand{\ei}{\end{itemize}} %Macros to make graphics insertions easy %Command for sizing to width \figw{file}{fraction of \textwidth} \newcommand{\figw}[2]{\centerline{\includegraphics[width=#2\textwidth]{#1}}} %Command for sizing to height \figh{file}{fraction of \textheight} \newcommand{\figh}[2]{\centerline{\includegraphics[height=#2\textheight]{#1}}} %Use \figh{graphics file name}{1} to size to whole text height %For graphics needing no shrinkage: \fig{file} \newcommand{\fig}[1]{\centerline{\includegraphics{#1}}} \newcommand{\foot}[1]{\footnotetext{#1}} % smaller text in bottom margin, e.g. citations \makeatletter \renewcommand\@makefntext[1]{\noindent#1} % see p. 114 of LaTeX Companion 2nd edition \makeatother \renewcommand\footnoterule{} \def\newblock{\hskip .11em plus .33em minus .07em} \logo{\figw{biostatLogo.jpg}{.123} \title[Short Title]{Long Title} \author[]{Jane Smith} \institute{Department of Biostatistics, Vanderbilt University School of Medicine} \date{\textsc{Meeting Title}\hfill presentation date} \begin{document} \frame{\titlepage} \frame{ \ft{Outline} \tableofcontents } \section{Current State} \frame{ \ft{Bad Practice} \framesubtitle{Be Good!} \begin{quote} Biases might pose a special challenge for laboratory researchers who are used to biological reasoning and the tightly controlled conditions of experimental research. Such researchers unwittingly become non-experimental observational epidemiologists when they apply molecular assays in studies of diagnosis and prognosis, for which the experimental method is not available and for which biological reasoning might have limited usefulness. \end{quote} \foot{\citet{ran05bia}; see also \citet{ran04rul}} } \frame{ \ft{Bad Statistical Practice} \bi \item Data torture \item Subsetting subjects \item Choosing cutpoints to optimize accuracy \item Incorrect accuracy measures \item Incomplete or no validation \item Overstatement of results \ei } \frame{ \ft{Bad Statistical Practice, \emph{cont.}} \bi \item No demonstration that information is new; not giving clinical variables same opportunities as potential biomarkers \item Poor use of continuous markers \item See REMARK guidelines \citep{mcs05rep}, \citet{ioa07mol}, \citet{chkaut} \ei } \frame{ \ft{A Slide Title} \begin{block}{Slide Subtitle1} \bi \item One \item Two \ei \end{block} \begin{block}{Slide Subtitle2} \bi \item Three \item Four \item Five \ei \end{block} } \section[Goals]{Statistical Goals} \frame{ \ft{Statistical Goals} \bi \item Experimental design, e.g. randomize processing order, blinding to patient outcome \item Understanding the measurements \item Analyzing assay variability/reliability \item Normalization (\textbf{better}: build into comprehensive model) \ei } \frame{ \ft{Demonstration of Added Information} \bi \item Biomarkers must add information to already available information \bi \item Partial test of association controlling for cheap info \item Index of information gain \ei \item Show that biomarker values cannot be predicted from existing data \item Insufficient number of cases to adjust for many clinical variables $\rightarrow$ propensity score analysis \bi \item Predict marker value from all clinical variables \item Solely adjust for predicted marker value \ei \ei } \section[Classification]{Problems with Classification} \frame{ \ft{Problems with Classification} \bi \item Proportion classified correctly is an \textbf{improper scoring rule} \bi \item Optimized by bogus model \ei \item Minimum information \bi \item low statistical power \item high standard errors of regression coefficients \item arbitrary to choice of cutoff on predicted risk \item forces binary decision, does not yield a ``gray zone'' $\rightarrow$ more data needed \ei \item Assumes statistician to be provider of utility function \item Sensitivity and specificity are also improper scoring rules \ei } \frame{ \ft{Example: Damage Caused by Improper Scoring Rule} \bi \item Predicting probability of an event, e.g., Prob(disease) \item $N=400$, 0.57 of subjects have disease \item Classify as diseased if prob.\ $>0.5$ \ei \begin{center}\begin{tabular}{lccc}\hline Model & $C$ & $\chi^{2}$ & Proportion \\ & Index & & Correct \\ \hline age & .592 & 10.5 & .622\\ sex & .589 & 12.4 & .588\\ age+sex & .639 & 22.8 & .600\\ constant &.500 & ~0.0 & .573\\ \hline \end{tabular}\end{center} \smaller[2] Adjusted Odds Ratios:\\ \begin{tabular}{ll} age (IQR 58y:42y) & 1.6 (0.95CL 1.2-2.0)\\ sex (f:m) & 0.5 (0.95CL 0.3-0.7) \\ \end{tabular} } \section{Validation} \frame{ \ft{Need for Stringent Validation} \bi \item Splitting a sample does not provide external validation \item Split-sample validation is terribly inefficient and arbitrary unless $>$ 20,000 subjects \item Greater reliability obtained by using all subjects and using bootstrap or 50 repeats of 10-fold cross validation \ei } \section{Dichotomania} \frame{ \ft{Problems Caused by Chopping Continuous Variables} \bi \item Chopping predicted probabilities causes major problems \item Many problems caused by chopping predictors \item True cutpoints do not exist unless risk relationship discontinuous \ei \begin{tabular}{cc|cc} \\ \hline Range of Delay & Mean Score & Range of Delay & Mean Score \\ \hline ~0-11 & 210 & 0-3.8~~& 220 \\ 11-20 & 215 & 3.8-8~~& 219 \\ 21-30 & 217 & 8-113~~& 217 \\ 31-40 & 218 & 113-170& 215 \\ 41-~~ & 220 & 170-~~~& 210 \\ \hline \end{tabular} \foot{\citet{wai06fin};~~See ``Dichotomania'' \citep{sen05dic} and \citet{roy06dic}} } \frame{ \ft{Data from Wainer [2006]} \figh{wai06fin}{.9} } \section[Continuous Markers]{Value of Continuous Biomarkers} \frame{ \ft{Value of Continuous Biomarkers} \bi \item Avoid arbitrary cutpoints \item Better risk spectrum \item Provides gray zone \item Increases power/precision \ei } \frame{ \ft{Prognosis in Prostate Cancer} % Put comments to the right of a figure; reserve 20% of the width for this \begin{columns} \column{.8\textwidth} \figw{psa}{.9} \column{.2\textwidth} \smaller[2]Data courtesy of M Kattan from JNCI 98:715; 2006 \\[4ex] Horizontal ticks represent frequencies of prognoses by new staging system \end{columns} } % Graphic taking up whole frame \frame{ \ft{Prognosis in Prostate Cancer, \emph{cont.}} \figw{/home/harrelfe/tmp/spectrum}{.725} } % Graphic taking up whole slide, with no header, footer, etc. \begin{frame}[plain] \figw{myplot}{1} % or \centerline{\includegraphics[angle=-90,width=.65\textwidth]{myplot}} etc. \end{frame} \frame{ \ft{Prognosis after Myocardial Infarction} \figw{troponin}{.75} \foot{\citet{ohm96car}} } \section{Summary} \frame{ \ft{Summary} \bi \item Current state of biomarker analysis leaves much to be desired \item Many statistical and epidemiologic problems, especially: \bi \item bias \item overfitting and overstatement \item incomplete validation \ei \item Cutpoints are inherently misleading \item Picking winners $\equiv$ splitting hairs \item Analyze clinical data as aggressively as potential biomarkers \ei } \begin{center} % omit this and next 5 lines if no bibliography \textbf{References} \end{center} \smaller[5] \bibliographystyle{abbrvnat} \bibliography{/home/harrelfe/bib/feh} %Note: If references will fit on one slide use: \frame{ \ft{References} \smaller[5] \bibliographystyle{...} \bibliography{...} } \end{document}

Inclusion of R Code or Verbatim Text

To include verbatim text, use the long form of the environment with the option: \begin{frame}[fragile] ... {\smaller % optional, using relsize style \begin{verbatim} . . . \end{verbatim} } % optional \end{frame} To include S language code in your presentation use the following model. \usepackage{alltt} \newcommand{\Gets}{\(\leftarrow\)} \newcommand{\Twiddle}{\mbox{\(\tt\sim\)}} \newcommand{\bex}{\begin{alltt}} \newcommand{\eex}{\end{alltt}} ... \begin{document} ... \frame{ \ft{An Example} Here is the code used to produce the previous result. \bex f \Gets lm(y {\Twiddle} age + sex) summary(f) a \Gets b + d \eex }