Book Image

LaTeX Cookbook

By : Stefan Kottwitz
Book Image

LaTeX Cookbook

By: Stefan Kottwitz

Overview of this book

LaTeX is a high-quality typesetting software and is very popular, especially among scientists. Its programming language gives you full control over every aspect of your documents, no matter how complex they are. LaTeX's huge amount of customizable templates and supporting packages cover most aspects of writing with embedded typographic expertise. With this book you will learn to leverage the capabilities of the latest document classes and explore the functionalities of the newest packages. The book starts with examples of common document types. It provides you with samples for tuning text design, using fonts, embedding images, and creating legible tables. Common document parts such as the bibliography, glossary, and index are covered, with LaTeX's modern approach.You will learn how to create excellent graphics directly within LaTeX, including diagrams and plots quickly and easily. Finally, you will discover how to use the new engines XeTeX and LuaTeX for advanced programming and calculating with LaTeX. The example-driven approach of this book is sure to increase your productivity.
Table of Contents (19 chapters)
LaTeX Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a large poster


We have seen informational or scientific posters at conferences or on the walls of universities or institutes. They mostly have certain characteristics in common:

  • They have a large size, such as A2, A1, or even A0

  • People may look at them from far away, but also from a very short distance

In consequence, we get some requirements for typesetting:

  • The page layout dimensions should work with such a big size.

  • We need a wide range of font sizes. We should be able to read while standing close, but we also need large, catchy headings.

  • The poster should be partitioned into digestible blocks. Specifically, each block should not exceed the usual line width we know from body texts. Also, excessively wide lines will make it hard to focus and to skip back to the start of the next line. So, the lines in blocks should not be much wider than about 40 or 50 characters long.

  • Blocks should have distinct headings.

  • Graphical elements such as colors and lines can be used to divide the poster contents in parts.

  • Images should be vector graphics or should have a high resolution.

In this recipe, we will create a poster of A0 size in landscape orientation. It will show some blocks containing the dummy text as a placeholder, math, and images. As sample images, we will take a flowchart from Chapter 9, Creating Graphics, and a plot from Chapter 10, Advanced Mathematics. There, you can find the source code. You can later replace the dummy text and other parts with your own content.

How to do it...

We will use the tikzposter class. The document is structured in columns and blocks. Follow these steps:

  1. Begin with the document class. A0 is the default paper size. We state landscape orientation as the option:

    \documentclass[landscape]{tikzposter}
  2. Choose a theme, which provides a set of colors and decorations. We choose the blue Wave theme:

    \usetheme{Wave}
  3. Load the lipsum package to generate the dummy text:

    \usepackage{lipsum}
  4. For dividing wider blocks in text columns, we load the multicol package. On account of the large paper, we set the column separation and the separation line width to high values:

    \usepackage{multicol}
    \setlength{\columnsep}{4cm}
    \setlength{\columnseprule}{1mm}
  5. Define macros for repeated tasks, if desired. In our case, it will be a macro for including an image with an optional caption:

    \newcommand*{\image}[2][]{%
      \begin{tikzfigure}[#1]
        \includegraphics[width=\linewidth]{#2}
      \end{tikzfigure}}
  6. Start the document:

    \begin{document}
  7. Declare the author and title, and print it out:

    \title{\LaTeX\ in Use}
    \author{John Doe}
    \maketitle
  8. Begin a set of columns:

      \begin{columns}
  9. Start a column with a width of 65 percent of the available text width:

      \column{.65}
  10. Define a block with the title Workflow in the first argument; the second argument containing dummy text and an image:

      \block{Workflow}{
        \lipsum[1]
        \image[\LaTeX\ workflow]{flowchart}
      }
  11. Still in the first column, start a set of subcolumns:

      \begin{subcolumns}
  12. The first subcolumn will take half of the available width, in this case, the width of the left column:

        \subcolumn{.5}
  13. Create a block with a bulleted list and a mathematical equation to get a feeling of how it will look on a poster. We will also use a colored box and an inner block with a title for the equation:

        \block{Mathematics}{
          Take a coffee, then:
          \bigskip
          \coloredbox{\begin{itemize}
            \item State
            \item Proof
            \item Write in \LaTeX
          \end{itemize}}
          \bigskip
          \innerblock{Integral approximation}{
            \[
              \int_a^b f(x) dx \approx (b-a)
                \sum_{i=0}^n w_i f(x_i)
            \]
          }
        }
  14. Add a note, which will have a callout shape, pointing to the formula:

        \note[targetoffsetx = 4.5cm, targetoffsety = -5cm,
          angle = -30, connection]{Weight function}
  15. Make another subcolumn, taking the other half of the available width. Insert a block filled with text and end the subcolumns environment:

        \subcolumn{.5}
        \block{Text}{\lipsum[1]}
      \end{subcolumns}
  16. Now that we are back to our main column environment, make another column, print a block with an image and some text, and then end the columns environment:

      \column{.35}
      \block{Plotting functions}{
        \image{plot}
        \lipsum[4]
      }
    \end{columns}
  17. As we ended the columns, a block will use the whole available width. To keep the text readable, we will now use the multicol package. We divide the text itself into columns using a multicolumn environment with four columns:

    \block{Conclusion and outlook}{
      \begin{multicols}{4}
        \lipsum[10-11]
      \end{multicols}
    }
  18. End the document:

    \end{document}
  19. Compile the document, and take a look:

How it works...

The tikzposter package supports large paper sizes, large fonts, and it takes care of block heights and spacing between columns. We, as users, just decided the relative column width.

Several class options are provided. You can add them to the \documentclass command like we did with the preceding landscape option. Let's take a look at the following:

  • The paper size can be chosen with the a0paper, a1paper, or a2paper options. The a0paper option is the default.

  • The available font sizes are 12pt, 14pt, 17pt, 20pt, and 25pt. The last one is the default.

  • You can select the orientation by using the landscape or portrait command. The portrait option is the default.

  • The standard option fleqn for flush left equations is supported.

  • The standard option leqno for numbering the equation at the left-hand side is also supported.

You can adjust several lengths using different options. Give them as class options in the key=value form with a measurement unit such as mm or cm:

  • margin: This is the distance between the edge of the poster area and the edge of the paper

  • innermargin: This is the distance from the outermost edge of the blocks to the edge of the poster

  • colspace: This is the horizontal distance between consecutive columns

  • subcolspace: This is the horizontal distance between consecutive columns in a subcolumn environment

  • blockverticalspace: This is the distance between the bottom of a block and the top of the next block

A sample call using the defaults will be as follows:

\documentclass[a0paper, portrait, 25pt, margin=0mm,
  innermargin=15mm, colspace=15mm, subcolspace=8mm,
  blockverticalspace=15mm]{tikzposter}

The tikzposter package makes use of the very capable graphics language TikZ. We will see more of TikZ in Chapter 9, Creating Graphics. For now, the main benefit is that tikzposter provides a lot of predefined styles and color schemes.

You can use a main layout style by using the \usetheme{name} command. When this book came out, there were nine themes available:

  • Wave: This can be seen in our preceding recipe

  • Default (left) and Basic (right): This is shown in the following image:

  • Rays (left) and Simple (right), as shown in the following image:

  • Envelope (left) and Board (right), as shown in the following image:

  • Autumn (left) and Desert (right), as shown in the following image:

Furthermore, there are predefined styles for color, title, background, notes, blocks, and inner blocks, which can be chosen and composed. There's support for creating further styles.

The commands, which you have seen previously, can be used without support options straight away. However, they can be customized using several options.

The full reference is available by typing the texdoc tikzposter command in Command Prompt, and online at http://texdoc.net/pkg/tikzposter. You can find a style guide, a feature guide, and much more at https://bitbucket.org/surmann/tikzposter/downloads.

There's more...

One of the first poster classes is a0poster. It actually supports the paper sizes A0, A1, A2, and A3. It provides font sizes from 12 pt up to 107 pt. Math formulas are printed in a suitable size. There's no specific support for graphics, color, or text placement. For this, you would need additional packages, such as TikZ.

In the recipe Creating a presentation, you saw the beamer package as a presentation class. The beamerposter package can be used together with it to produce presentations in poster size. It combines the beamer package with the a0poster code. So, you can produce large posters with a wide range of font sizes together with the beamer package's color and graphics capabilities, such as the beamer boxes with titles.

As mentioned previously, you can use the texdoc command or the Internet site http://texdoc.net to access the documentation of the aforementioned classes and packages.

Another solution is provided by the baposter template. It provides blocks with headings and positioning support. Furthermore, it offers a set of predefined styles. Its download and documentation are available at http://www.brian-amberg.de/uni/poster/.