About these ads

Latex page, line and font settings

I was recently asked to write a three page assignment/case study using the following page, line and font settings:

  • Arial, size 12
  • 1.5 line spacing
  • 2.5cm margin all round

Let’s do one by one.

 

Font type and size

Font types are actually a bit of a pain in Latex and so far, I have almost always been using the standard font, Knuth’s Computer Modern. The reason for not using the fonts provided by the system is that Tex and Latex will give the same distinctive look no matter which platform a document was compile on, making the language system independent.

Some fonts are available, including Times Roman, Helvetica and Courier. Arial however is a “non-free-font” from Microsoft and has to be installed manually — I give up, it’s getting late and I tried various things without success, including installation of the Arial font family.

I will go with XeLaTeX using system fonts, nice :-) .

\documentclass[11pt]{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{fontspec}
\setmainfont{Arial}
\begin{document}
\blindtext
\end{document}

Another, less clean approach I came across uses Latex with the following two lines added to the preamble:

\renewcommand{\rmdefault}{phv}
\renewcommand{\sfdefault}{phv}

It changes the font family to Helvetica, which is very similar to Arial, but it’s not the same.

The font size is easy, just use the documentclass option:

\documentclass[12pt]{article}

This brings me to the next point on the list above. I will stick to XeLaTeX, but all the examples will perfectly work with LaTeX, assuming you are using Helvetica and not Arial.

 

Linespacing

Basically, 1.5 line spacing is done using the setspace package as follows:

\usepackage{setspace}
\onehalfspacing

Please see my previous post on that topic for more details on line spacing.

 

Setting the margins

If you are lucky enough to require an equal margin on all sides, the geometry package with the margin option will do the trick:

\usepackage[margin=2.5cm]{geometry}

For different margins on every side, the package provides four options: top, left, bottom, right:

\usepackage[top=1.2in, left=0.9in, bottom=1.2in, right=0.9in]{geometry}

See the package documentation for more details.

 

Complete example (XeLaTeX)

\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage{blindtext, fontspec, setspace}
\usepackage[margin=2.5cm]{geometry}
\setmainfont{Arial}
\onehalfspacing
\begin{document}
\blindtext
\end{document}

Customizing font, margins and line spacing.

Please leave me a comment if you know of a simple and nice tutorial on how to install non-free-fonts like Arial. Thanks!

About these ads

16 Responses to “Latex page, line and font settings”

  • MiguelV

    Excellent! Thanks a lot for your tips

  • Janssen

    Do you really think someone asking for a document in Arial with 1 inch (2.54 cm) margins would be able to spot the differences between Arial and Helvetica?

    • tom

      Thanks for your comment. Your are right, he certainly wouldn’t. My intention was to tell people there is a difference. I probably felt it’s not clean because the source I got the code from doesn’t mention it’s not Arial, but Helvetica. I should have provided that link before though.

      Cheers, Tom.

  • Roel

    Using XeLaTeX is a sort-of all powerful method to use any font you’d like and it works almost flawlessly. Why would you want to go through a lot of hassle – if it is at all possible – to convert a commercial font to be used with LaTeX?

    Btw, blindtext is a nice change for using lipsum. Thanks for the suggestion :)

    • tom

      Hi Roel, you are right, XeLaTeX is indeed very powerful and there is no reason for not using it in most cases. XeLaTex has some drawbacks (see the discussion on tex.SE. In the end, it’s up to the writer whether he can live with the drawbacks or prefers to stick to the standard fonts provided by TeX.

      Yes, blindtext is great, I’ve been using it extensively, since I discovered it.

      Best, Tom

  • Lian Tze

    Have you tried the winfonts package? http://ctan.org/tex-archive/fonts/winfonts
    It’s not available in TeXLive nor MikTeX, so you’ll have to install it manually.

    You’ll also have to tell LaTeX where to find arial.ttf etc, either by setting OSFONTDIR, or by copying the TTF files to somewhere like LOCALTEXMF/fonts/truetype/microsoft/ .

    Then to use Arial as the default font:

    \usepackage[T1]{fontenc}
    \renewcommand{\sfdefault}{arial}
    \renewcommand{\familydefault}{\sffamily}
  • Humberto

    Hi Tom,

    In my output file I got an empty page, after the Appendix B. How I can delete this empty page?

    Regards,

    Humberto

  • ricky

    when i run on my latex with eclips (texlip) i got thet one “>><<" i dont know what it mean. but thx for "\blindtext". its new for me. n_nV

    • tom

      Hi Ricky, please provide a minimal example that illustrates the problem. The code should be independent of the editor, texlipse is just an eclipse plugin. Thanks, Tom.

  • Humberto
    \documentclass[12pt]{report}
    \usepackage{latexsym,subrthesis1}
    \usepackage{graphicx,subfigure}
    \graphicspath{converted_graphics}
    \begin{document}
    \pagestyle{headings}
    \pagenumbering{arabic}
    \chapter{Introduction} 
    \thispagestyle{empty}
    \chapter{Numerical Derivation}
    \thispagestyle{empty}
    \appendix
    \chapter{List of Symbols}
    \thispagestyle{empty}
    \end{document}

    Hi Tom the above minimal example is a simplified structure of my document. In the real document, a blank page is created at the beginning of the appendix, without a page number, and the next page contains the beggining of the appendix with the next page number. I just want to remove the blank page. .

    I will appreciate any suggestion you can provide me.
    Thanks,
    Humberto

    • tom

      Hey Humberto,

      From your minimal example I can’t see the behavior you’re describing. It may be due to the fact that I didn’t have the subrthesis1 package and can’t tell what it does. Have you tried not loading that particular package? Do you use the documentclass options twoside and openright?

      Please provide a minimal example that illustrates the issue.

      Thanks, Tom.

      • Humberto

        Hi Tom,
        Below is the illustrative minimal example. I include part of the thesis style for our master program. I think the problem was caused when the student changed the command \baselinestrecht.

        Thanks for any advise.

        Humberto

        ——————————————-

        [...]Code removed by Tom[...]

      • tom

        Hi Humberto,

        Sorry to remove your code and spoil your document, I removed the parts which were not necessary to illustrate the cause. As you can see from the code below (what is left from your document), the problem is caused by the stretch, as you already guessed. Actually, the appendix reaches into the margin, because array doesn’t add a page-break automatically. What I would suggest, if you can live with it, is to change the arraystretch back to 1. The two commands arraystretch and baselinestretch add up to stretch what is already stretched. Here is the code that illustrates the problem. Try commenting out arraystretch or set it to 1.2.

        Thanks for the example, it helped a lot. Let me know if you have any other questions. Best, Tom.

        \documentclass[12pt]{report}
        \usepackage{latexsym, blindtext}
        \usepackage{show frame}
        \topmargin -18pt \headsep = 15pt
        \textheight 8.9in \textwidth 6in
        \renewcommand{\baselinestretch}{1.6}
        \begin{document}
        \everymath{\displaystyle}
        \renewcommand\arraystretch{1.5}
        \thispagestyle{empty}
        \tableofcontents
        \blinddocument
        \appendix
        \pagestyle{headings}
        \chapter{List of Symbols}
        \thispagestyle{empty}
        The following is the list of all symbols used in this thesis.
        \begin{displaymath}
        \begin{array}{rl}
        T:& \textrm{Temperature measured in the range of} 1-600^{\circ} C \\
        &\textrm {it rises at a constant pre-set heat rate } \beta \\
        \beta:& \textrm{Controlled heating rate with values } 1, 2.5, 5, 10, 15 \textrm{ and } 30^\circ C/min\\
        \beta:& \frac{dT}{dt}\\
        t:& \textrm{Time of the experiment measured in half of second}\\
        M_0:& \textrm{Initial mass, it measures } 15\pm 1 mg\\
        M_t:& \textrm{Mass at time } $t$\\
        M_f:& \textrm{Final mass} \\
        T_i:& \textrm{Initial temperature}\\
        T_f:& \textrm{Final temperature}\\
        T_i-T_f:&	\textrm{Reaction temperature interval} \\
        T_m:& \textrm{is the temperature corresponding to the maximum of $\frac{d\alpha}{dT}$}\\
        \end{array}
        \end{displaymath}
        \end{document}
  • Humberto

    Hi Tom,

    Thanks so much for your advice. I changed back arraystretch to 1 and baselinestretch to 1.5. It works perfectly.

    Thanks so much

    Humberto

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 714 other followers

%d bloggers like this: