Q: How to let the cited references have the form "authors (year)" instead of "[1]" say?

You can use the package "natbib". The following is an example:

documentclass[12pt]{article}
usepackage[super, sort]{natbib}
bibpunct{(}{)}{;}{a}{,}{,} % required for natbib

begin{document}

Use the natbib package with options texttt{super} and texttt{sort}, 
and use verb+citep+ or verb+citet+
instead of the command verb+cite+. In detail, we need to include the 
natbib package
and include the line

begin{verbatim}
bibliographystyle[super, sort]{natbib}
bibpunct{(}{)}{;}{a}{,}{,}
end{verbatim}

in the preamble. 

And use the bibliographstyle texttt{plainnat}, i.e.
verb+bibliographystyle{plainnat}+.

The command
verb+citet+ is for ``last name (year)'' and verb+citep+ for 
``(last name, year)'' which will be shown in the text.


The result of verb+citep{GoossensEtAl:1999}+ is citep{GoossensEtAl:1999}.
The result of verb+citetcitet{GoossensEtAl:1999}+ is citet{GoossensEtAl:1999}.

bibliographystyle{plainnat} % required for natbib
bibliography{workshop}

end{document}

The content of the file "

workshop.bib

" is below:

@book{GoossensEtAl:1999,
  author="{Goossens, M.} and {Rahtz, S.} with {Gurari, E., M.} and {Moore, R.} and {Sutor, R.  S.}",
  title="The LaTeX, Web Companion",
  publisher="Addison-Wesley",
  year="1999"
} 

You can copy the above two files to your computer and compile them to see the

result

.

Q: How do you make a PDF document from a TeX/LaTeX formatted file?

To make PDF documents from a TeX or LaTeX source, use one of these commands:

         pdftex file.tex  ... or ...      pdflatex file.tex 

substituting file.tex for the filename of your TeX/LaTeX sources. The output ought to be be in

  file.pdf 
Q: Using pdflatex/pdftex/dvipdfm as part of teTex

Below are ways to get from TeX/LaTeX to a pdf file. These approaches are highly recommended over the use of ps2pdf, which does a bitmap conversion (resulting in a huge pdf file that is not searchable by words).

Converting latex: pdflatex without graphics

Just run pdflatex.

back to top

Converting latex: pdflatex with graphics

To include figures in latex, the "best" approach is with the graphicx package:

   \documentclass{article}
   \usepackage{graphicx}

or

   \documentstyle[graphicx]{article}

Then figures are included with something like

   \includegraphics[angle=-90,totalheight=4in]{plot}
   \includegraphics[totalheight=4in]{plot}
   \includegraphics[totalwidth=6in]{plot}

or

   \includegraphics[width=3in, height=4in]{plot}
   \includegraphics[width=7.5cm, height=10cm]{plot}

The use of \totalheight or \totalwidth is preferable in order that text characters are proportional and not squished in one direction.

Just run pdflatex or latex. For the above, pdflatex assumes a file plot.pdf exists, and latex assumes a file plot.ps exists

back to top

Converting figures as ps files to pdf: ps2pdf, epstopdf

To convert a figure from postscript (ps file) to pdf, use the ps2pdf command. If this fails, then try epstopdf. This conversion is needed to include graphics for pdflatex. In pdflatex, graphics types allowed are pdf and png, but not ps.

back to top

Converting dvi to pdf: dvipdfm

dvipdfm is currently only available on the Linux computers, not the Solaris computers.

dvipdfm converts a dvi file directly to pdf, without changes in the TeX/LaTeX file. The resulting file is searchable. Different graphics type (eg., jpeg, gif) can be used with the graphicx package in LaTeX; these cannot be seen with xdvi but they can be seen from acroread after the dvi file is converted to pdf.

Sometimes dvipdfm works better than pdflatex (e.g., slides using the 'seminar' style).

Q: Common TeX/laTex errors

This is a list of common TeX/LaTeX errors that I see when reviewing manuscripts. Also some shortcuts are given to make math equations more readable (and easier to edit).

Note the \def (or \newcommand) should appear at the beginning of your tex file (before \begin{document} in LaTeX).

  • If you look carefully at math writing, variables are printed in the italics or slanted font. However something like the exp or log function is not a variable, so it is in standard font, even within math mode. That is, \exp, \log, \sin etc are used for math and trigonometric functions. For statistics, \Pr is a definition for probability of an event, but \E for expectation and \Var for variance, etc, are not defined.

    However, you can define these yourself with something like

         \def\Var{\mathop{\rm Var}} 
    

    or

         \def\Var{{\rm Var}\,}
         \def\E{{\rm E}\,}
    
    

    The first version does not work well for E.

  • Math expressions with subscripts and superscripts should also be put in math mode, e.g., $a$, $x=1$, $-1$. In non-math mode, - is a hyphen (shorter than minus sign, -- is an en dash (e.g. for pp. 34--43), and --- is an em dash — for use in a middle of a sentence.
  • Unless you are in displayed math mode, fractions should usually be expressed with a solidus, for example $x_i/n$ and not $\frac{x_i}{n}$ or ${x_i\over n}$.
  • Use a definition for any math symbol with a 'hat', 'bar', 'tilde' etc. This will make equations easier to read in TeX. Same thing for symbols for equal in distribution, convergence in probability, etc. Examples are:
        \def\phat{{\hat p}} 
        \def\Fbar{{\overline F}}
        \def\atil{{\tildealpha}}
        \def\inprob{\rightarrow_p}
        \def\eqd{\,{\buildrel d \over =}\,} 
        \def\law{\rightarrow_d}
    
  • boldface Greek in scriptsize: LaTeX may not automatically resize a symbol when it is a subscript of superscript. Hence def are needed for scriptsize characters, e.g.
      \def\thbf{\mbox{\boldmath $\theta$}
      \def\thbfs{\mbox{\scriptsize \boldmath $\theta$}}
      $$f(\thbf) =2^{\thbfs}$$
    

    Alternatively, use the ams packages amsmath and amssymb

      \def\dbfams{\boldsymbol{\delta}}
      \def\mubfams{\boldsymbol{\mu}}
    
  • labelling of equations, and theorems, lemmas, corollary: 
    To get the section number to appear in an equation, add (to the beginning):
        \renewcommand{\theequation}{\thesection\.\arabic{\equation}}
    

    and add

        \setcounter{\equation}{0}
    

    at the beginning of each section.

    To get Theorems, Lemmas, Corollaries to be on the same numbering scheme, by section, add:

        \newtheorem{\theorem}{Theorem}[section]
        \newtheorem{\lemma}[theorem]{Lemma}
        \newtheorem{\corollary}[theorem]{Corollary}
    
  • larger brackets[], braces{}, parentheses(): these should be used around summations, fractions etc. It is simplest to use \left[, \right] etc, but left and right only work if your equation is not split into more than one line. In the latter case, use one of \bigl, \Bigl, \bbigl, \Biggl (and corresponding \bigr on the right).

    Sometimes one needs a larger '/' or '|'. For '/', use \bigm, \Bigm etc. For '|', use \bigl, \bigm, \bigr etc depending on whether it is left, middle or right.

Q: How to wrap text around the figure or table?

You can use either floatflt package or wrapfig package.

For example:

\begin{floatingfigure}[r]{0.4textwidth}
\centering
\includegraphics[width=0.4textwidth]{lake1}
\caption{Text wrap around figure}
\noindent \hrulefill
\label{test}
\end{floatingfigure}

and

\begin{wrapfigure}{r}{0.4textwidth}
\centering
\includegraphics[width=0.4textwidth]{lake1}
\caption{Text wrap around figure}
\noindent \hrulefill
\label{test}
\end{wrapfigure}

The difference between floatingfigure and wrapfigure is that the text typed after end{floatingfigure} will be forced to be a new paragraph.

For more information, please refer to floatflt manual and a webpage about wrapfig.

Q: Writing thesis (PhD or MSc) in LaTeX

There is a class file for LaTeX2e that helps you produce a properly formatted UBC thesis. It's not officially supported by UBC but has been endorsed by FoGS as mentioned on their webpage. The download link can be found in the LaTeX section there.

Just in case the FoGS website is down here is a direct download link provided by Michael McNeil Forbes, the author of the class file and a former UBC graduate student.
 

Q: Add StatNet printer using TCP/IP Jetdirect socket

Another way to add printer is use "Bonjour", IPP or TCP/IP printer.

TCP/IP method:
Name: hp5.stat.ubc.ca
IP: 142.103.175.193
Model:  Duplex, HP Laserjet M605 dn
Mailroom

Optra:  optra.stat.ubc.ca
IP: 142.103.175.197
Model:  Duplex, HP Laserjet M605 dn
ESB 3163

Mac OSX:
System Preferences -- Printers & Scanner -- + -- IP --
Address 142.103.175.193
HP JestDirect Socket
Queue Leave it empty
Name hp5
Location Mailroom
Use Select Software
Postscript
Add
NOTE: If you don't see "Postscript" software you need to follow instruction below.

Download new driver for HP Laserjet M605  and install on your computer first.

https://support.hp.com/ca-en/drivers/selfservice/hp-laserjet-enterprise-...

Install the driver and then add the printer.  You will see the HP M605

After this, Configure the HP5 to add Duplex option for duplex printing.
Keep everything else as Default setting.

Windows 7: http://www.tp-link.com/lk/article/?id=240

Windows 8: http://www.tp-link.us/article/?faqid=459
In Windows 8, Swipe from the right to left, click on Search " Advance Printer Setup"

Q: My printouts are not centered on the page but are offset. Why is this?

If you have a properly formatted file (i.e. it's text or a Postscript file that has been formatted for Letter (8.5"x11") size paper) but the output has been shifted right and/or down, it's likely that the printer is mistaken about the size of the paper in the print hopper.

The print hoppers has a slider that signals the printer on the type of paper loaded within (such as Letter, Legal, etc). It does this by moving fingers or knobs located on the side of the hopper that press against contacts within the printer. Sometimes either the fingers or the contacts are stuck and the printer is misinformed about the size of the paper. When a Letter size printout is being printed, the printer tries it best to print on the wrong size paper, thus the off-centered output.

The fix is two unstick the fingers or contacts so that the printer has the correct paper sizing information. If you don't know how to do this, contact the IT staff.

Q: How do I enable / disable two-up printing?

Two-up printing is where 2 pages are printed on one side of a paper by shrinking them, putting them side-by-side on a landscape format paper.

This is the usual default for printing text files. To disable this, you'll need to convert it to Postscript, as Postscript files are printed without reformatting:

      textps file.txt | lpr -Pprintername 

If you have a Postscript file, you can reformat them into a 2-up format (or even 4-up format if your eyesight can stand the strain) by filtering them through the psnup tool:

     psnup -2 file.ps | lpr -Pprintername    psnup -4 file.ps | lpr -Pprintername 

You can combine the above two solutions to print text in a 4-up format:

  textps file.txt | psnup -4 file.ps | lpr -Pprintername 

For Windows users, some printer drivers will allow you to set 1-up, 2-up, 4-up and booklet format.

Q: The printer says its out of paper or toner. What do I do?

If a printer is out of paper (the hoppers are empty and there no packages of new paper to be found near the printer), then a fresh package or box of paper can be fetched from the mail room. Before you take some paper, please notify the Font Desk Receptionist so that the inventory can be kept up to date. If possible, please take an entire box so that this tiresome exercise need not be repeated often.

If the printer reports in the LCD window that it is low on toner, then what to do depends on how fresh this message is. The toner sensor is very conservative and will report "Low Toner" even though there is plenty of life left. To ascertain whether the toner is really running out, print a test page. If the printout is getting very light or has bald patches, then open the printer, shake the toner cartridge, reinsert the cartridge and print a few test pages again. If it comes out spotty again, then it's time to change ther printer cartridge.

Contact the IT staff to replace the cartridge.

Pages