L A TEX Document Formatting Examples

Similar documents
Introduction to Scientific Typesetting Lesson 7: Graphics and Floats

The Honours Dissertation Class for L A TEX2e. Cara MacNish

Square cells: an array cooking lesson

A Case When eval is Necessary

L A TEX: Online module 6

Including Graphics in L A TEX Files

Helen Cameron. A Brief Overview of LATEX

The isorot Package User Manual

Intro to LATEX I. Aaron Erlich POLS/CSSS 510, Why LATEX? Programming Document Structure Floats Tables Lists Math

Creating Tables and Figures with L A T E X

Getting Started with L A T E X for a Technical Document or Thesis

Intro History Version 2 Problems Software Future. Dr. StrangeBook. or: How I Learned to Stop Worrying and Love XML. Nigel Stanger

StarT E X at E X for beginners

L A TEX Course at ICT School

LaTeX A Tutorial. Mohsen Alimomeni, 2010

MATLAB for the Sciences

L A TEX Tutorial. 1 Introduction. 2 Running L A TEX. J. E. Rice. May 2010

Rotating Text, Tabulars and Images. Herbert Voß March 3, 2007

PHYS-4007/5007: Computational Physics

The basics of LaTeX. Cédric Buron. April 25, 2016

The Table and Figure Environments

Introduction to L A TEX

Getting Started with L A TEX

L A TEX examples. a b c a b c b b a c b c c b a. This table was typeset with the following commands.

The gnuplottex package

Dec. 27 th, 2010 University of Isfahan

Getting started with Latex

An Introduction to LATEX

Compressed Images in PostScript and PDF with L A TEX HOWTO

Began as TeX, in 1982 (Knuth). Purely a typesetting tool. LaTeX added macros, maintaining TeX as it s typesetting engine (Lamport).

1 Introduction. 2 About L A TEX. Page 1(6) Why LATEX is used for review report typesetting within the TDB. project

Parsing INI Files in Lisp

L A TEX: Eh? What is it, what isn t it, who cares? Andy Caird. LATEX: Eh? p.1/13

L A TEX Overview. Jiayi Liu. January 31, Colorado School of Mines

TUGboat, Volume 22 (2001), No. 1/2 87

Introduction to LaTeX. Paul Fodor Stony Brook University

What is T E X? T E X and L A T E X Document preparation tools. Setting and casting type. What Knuth was setting. Setting and casting type

PoS author manual. PoS author manual. PoS Editorial Office S.I.S.S.A. - Via Beirut 2/4 Trieste, Italy

Lecture 2: Tables, Figures and Formulæ

An introduction to L A TEX for students

An Introduction to L A TEX

An introduction to LaTeX

CSCM10 Research Methodology A Taster of L A TEX

WYSIWYG Systems. CSCM10 Research Methodology A Taster of L A TEX WYSIWYM. Advantages/Disadvantages of WYSIWYG Systems.

CpSc 101, Fall 2015 Lab7: Image File Creation

The multicap L A TEX2ε package

Learning L A TEX. Patrick Lam

David Helmbold, October 2005, Revised October 2007

1. Please, please, please look at the style sheets job aid that I sent to you some time ago in conjunction with this document.

COMS 6100 Class note

Latex Tutorial. CIS400 Senior Design 9/5/2013

A brief introduction to L A TEX

Rich Text Editor Quick Reference

LATEX, BibTEX, and Friends. Robert Buels. Outline. What is LATEX. Using BibTEX LYX the graphical LATEX Managing your BibTEX references Further reading

Perceptive Document Composition

Latex Manually Set Font Size For Tables

A Short Introduction to L A TEX

An introduction. C.D. Emmery & M.M. van Zaanen. October 22, Tilburg University

A quick guide to L A TEX

Drawing Trees with PStricks

Separable Kernels and Edge Detection

Latex Tutorial 1 L A TEX. 1.1 Text

Introduzione a LaTex. Fabrizio Messina

Mikkel Madsen

INTRODUCTION TO L A TEX

How to get started in L A TEX

Become a L A TEX Guru

Assessments for CS students:

Indian T E X Users Group

Indian T E X Users Group

Mr G s Java Jive. #11: Formatting Numbers

A demonstration of the L A TEX2ε class file for Earthquake Engineering and Structural Dynamics

Must Have Graphic Tips

A demonstration of the L A TEX2ε class file for the International Journal of Network Management

Lecture 5 - Graphics and PStricks

A Demonstration of the L A TEX 2ε Class File for the Oxford University Press Ltd Journal. First Author 1 and Second Author 2.

Word-to-L A TEX specification

Environments, Equations, and Tables

Explanatory note on the LaTeX thesis template. Basic knowledge of using LaTeX

An Interactive Introduction to L A TEX. Part 2: Structured Documents & More. Dr John D. Lees-Miller. writel A TEX.

Lecture 1. MA2730: Analysis I. Lecture slides for MA2730 Analysis I. Study and Assessment Components. MA L A TEX: topics for Lecture 1

The first thing we ll need is some numbers. I m going to use the set of times and drug concentration levels in a patient s bloodstream given below.

The FigSize Package. Anthony A. Tanbakuchi. v0.1 last revised 2002/3/18. Abstract

L A TEXcourse. Carmen Alonso Montes. 30th May-2nd June, 2016

MY DOCUMENT FILE epoint.edu.vn MY DOCUMENT FILE. page 1 / 5

StarTEX A TEX for Beginners

Helen Cameron. A Brief Overview of LATEX

Solution Guide for Chapter 20

2013 Association Marketing Benchmark Report

The catechis Package, v2.1

Introduction to Scientific Typesetting Lesson 1: Getting Started

Typesetting Mathematics. Dr. C. F. Rocca Jr.

The Joys of L A T E X

ORB Education Quality Teaching Resources

Using LaTex and BibTex to Write Academic Documents. Ligang He Department of Computer Science University of Warwick

Introduction to LaTeX. Christoph Pickl

A Short L A TEX Introduction

An introduction to LaTeX

How to L A TEX. George Wong, David Mykytyn. 6 October 2016

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners

Transcription:

L A TEX Document Formatting Examples Gene Michael Stover created Thursday, 2005 May 19 updated Sunday, 2005 November 20 Copyright c 2005 Gene Michael Stover. All rights reserved. Permission to copy, store, & view this document unmodified & in its entirety is granted. Contents 1 What is this? 1 2 Summary 2 3 Pictures in Figures 2 4 Images outside of figures 6 5 The includegraphics command 7 6 Text Flowing Around Pictures 7 6.1 Attempt 1, Failure.......................... 7 6.2 Attempt 2, Partial Success...................... 8 7 Figures with borders 8 7.1 usepackage float / boxed technique................. 9 A Other File Formats 11 1 What is this? Most of what I do here is discussed in one or more of these sources: L A TEX: A Document Preparation System. By Leslie Lamport. [4] The L A TEX Web Companion: Integrating TEX, html, and xml. By Michel Goossens and Sebastian Rahtz. [3] The L A TEX Companion. By Michel Goossens and Frank Mittelbach. [2], & 1

Graphics & Colour with L A TEX. By Patrick W. Daly. [1]. All I m doing in this essay is trying out what they say, figuring it out now so I can use it when I want it later. 2 Summary I found two ways to include images. They are: Inside a figure, using the \epsfig command. It works except that the html version loses the colour of the original encapsulated Post Script file. Outside of a figure. Use conditional compilation to place an encapsulated Post Script image in the printed output & a hyperlink in the html output. Works well except that I don t have much control over how the image is displayed. What I d really like to do is make text in a paragraph flow around a small image in both the printed output & the html output. I don t know how to do that yet. 3 Pictures in Figures Let s start with a colour jpeg image & put it in a figure so that it displays in both the html & the dead tree versions of the document. Figure 1 shows the figure. The idea is that it looks pretty much the same in the html & printed versions of this essay. Here s how I did that: 1. I began with a colour jpeg picture 1 that is 640 by 480. 2. Loaded the image into The Gimp 2. 3. Saved the image as a Post Script file. Options I used on the Safe As... window were: (a) Post Script level 2 (b) Encapsulated Post Script (c) Preserve aspect ratio (d) Units of millimeters (e) X & Y offsets of 1.00 & 1.00 1 http://cybertiggyr.com/gene/pho/2004-12/04-640.jpg 2 http://www.gimp.org/ 2

Figure 1: My cat, Wordsworth. 2004 December. 3

(f) Width & Height of 120 & 90. Those dimensions have the same ratio as 640:480. I experimented to find dimensions which were small enough for the printed page. (g) New filename of 04-640.ps 4. Near the top of the L A TEX source code for this document, I inserted \usepackage{epsfig}. 5. The L A TEX code for the figure is: \begin{center} \begin{figure} \epsfig{file=04-640.ps} \caption{my cat, Wordsworth. 2004 December.} \label{fig-colour-jpeg} \end{figure} \end{center} This technique seems to work for both the pdf output & the html output except that in the html version, L A TEX2html converted the encapsulated Post Script image to a Portable Network Graphics (png) file & lost the colour in the process. Some research shows that the loss of colour happens when pstoimg converts the encapsulated Post Script image to a png. I experimented with ways to run pstoimg from the command line, & everything I tried lost the colors, so fixing things is not just a matter of correcting how L A TEX2html invokespstoimg. Ideally, it would be a case of improving pstoimg. Not bad for a first try. I m surprised & not exactly pleased that, in the printed version, the figure is on the next page, by itself. If a future version of pstoimg preserves colours, this technique will be perfect for figures containing pictures. I tried using conditional compilation to use the Post Script image in the pdf output & a hyperlink to the jpeg in the html output, but no luck. The pdf output is fine, but the html output is a great big gray, featureless box. Figure 2 demonstrates. Here is the source code for Figure 2: \begin{figure} \begin{latexonly} \epsfig{file=04-640.ps} \end{latexonly} \begin{htmlonly} \htmladdimg{../pho/2004-12/04-640.jpg} \end{htmlonly} \caption{using conditional compilation for images in a figure. Should look fine in {\sc pdf}, but doesn t work in the {\sc html}.} 4

Figure 2: Using conditional compilation for images in a figure. Should look fine in pdf, but doesn t work in the html. 5

\label{fig-conditional-00} \end{figure} So that didn t work. 4 Images outside of figures If I don t need the image to be in a figure, conditional compilation works. Here is an image, outside of a figure, which uses \epsfig to load an encapsulated Post Script file for the pdf output & an hyperlink to the original image for the html version. It switches between the two commands with conditional compilation. Here s the L A TEX source code which displayed that image: \begin{latexonly} \begin{center} \epsfig{file=04-640.ps} \end{center} \end{latexonly} \begin{htmlonly} 6

\htmladdimg[align= CENTER ]{../pho/2004-12/04-640.jpg} \\ \end{htmlonly} That s pretty much what I want, though it only works outisde of a figure. 5 The includegraphics command I used \epsfig for the image. For the html version, that leads to the problem of lost colours because L A TEX2html must convert it to an image file. The \includegraphics command should allow us to use the raw image file for both the pdf & the html. Here are some commands I tried from the graphicx package, but they all produce errors at compile-time. I m not sure, but I think the dvips program may be the one which spews the error. Here are some things I tried from graphicx: \includegraphics[width=64mm,height=48]{../pho/2004-12/04-640.jpg} \includegraphics[bb=0 0 64mm 48mm]{../pho/2004-12/04-640.jpg} 6 Text Flowing Around Pictures 6.1 Attempt 1, Failure We ll start with a jpeg image. The one I used is at http://cybertiggyr.com/gene/dfx/thumb.jpeg. I got it from Google, & maybe I should make my own to avoid copyright problems. I saved it as an Encapsulated Post Script file, Post Script level 2, measuring 30 millimeters high by 40 millimeters wide, but I told the Gimp to preserve the aspect ratio, so the actual image might have a slightly differet size. Here s what I would try if I had the picins package on all my L A TEX computers. \parpic[sr][r]{\includegraphics{thumb.ps}} I used the\parpic command of the picins package to place the image to the right of this paragraph. I sure don t like the results. In the pdf output file, the image is taller than the paragraph that contains it, & L A TEX does not compensate by placing vertical space between that paragraph & the one which follows. What s more, the image is not included at all in the html output. 7

1. Given: Numbers a & b. 2. Let a 2 a a. 3. Let b 2 b b. 4. Let c 2 a 2 + b 2. 5. Let c c 2. 6. Return c. Figure 3: Pseudocode without a border 1. Given: Numbers a & b 2. Let a 2 a a 3. Let b 2 b b. 4. Let c 2 a 2 + b 2. 5. Let c c 2. 6. Return c. Figure 4: Pseudocode with a border 6.2 Attempt 2, Partial Success If I want text flow around the image in the html output, but I ll do without the image in the hard-copy version, I can use the \htmladdimg command to achieve it in the html version of the document. The printed version will not show the image at all, so the text will not flow around it. In the html version, this paragraph flows around an image on the right. In the printed version, there is no image. (New paragraph) It works fine. 7 Figures with borders Here s how to put a border around a figure so the reader can more easily see that it s a figure & not part of the text. Such a border is particularly useful for figures whose content is mostly text (such as pseudocode). This technique doesn t work well, so keep reading until you come to the usepackage float / boxed technique. Figure?? is a figure containing pseudocode & without a border. Table?? is an attempt at a bordered figure containing text by using a tabular environment inside the figure. Here is the source code for the figure with the border. \begin{figure} 8

\begin{center} \begin{tabular}{ rl } \hline 1. & Given: Numbers {\em a} \& {\em b} \\ 2. & Let $a^{2} \Rightarrow a \times a$ \\ 3. & Let $b^{2} \Rightarrow b \times b$. \\ 4. & Let $c^{2} \Rightarrow a^{2} + b^{2}$. \\ 5. & Let $c \Rightarrow \sqrt{c^{2}}$. \\ 6. & Return {\em c}. \\ \hline \end{tabular} \end{center} \caption{pseudocode with a border} \label{fig-pseudocod-borderless} \end{figure} Three bummers include: 1. Since it s a table, I must number each row myself. (A good L A TEX programmer could fix that, I m sure.) 2. Again since it s a table, multi-line entries could be difficult. I might have to insert line breaks. 3. Again since it s a table, nested steps will be difficult. 7.1 usepackage float / boxed technique Here s the best way I know so far to make a figure with a boarder. 3 Figure 5 shows a figure with a border. Well, that s what it shows in the L A TEX output, such as a dvi, PostScript, or pdf file. As of 2005 November 20, L A TEX2HTML does not convert it correctly, so you see a regular figure with boxed figure before it & plain figure after it. Let s get rid of the boxed figure & plain figure garbage in the html output. Figure 6 shows the result. So we get a figure with a border in L A TEX & a regular figure (often with a shaded background) in L A TEX2HTML. It s not exactly what I wanted, but it s good enough. Here s the source code for the previous figure: \ begin{latexonly} \floatstyle{boxed} \restylefloat{figure} \ end{latexonly} \begin{figure} \begin{center} \begin{enumerate} \item Given: Numbers {\em a} \& {\em b} 3 This supremely exactly what I was looking for technique was suggested by Mair. Many thanks, Mair. 9

1. Given: Numbers a & b 2. Let a 2 a a 3. Let b 2 b b. 4. Let c 2 a 2 + b 2. 5. Let c c 2. 6. Return c. Figure 5: Pseudocode with a border in L A TEX, with preceeding & following crap in html 1. Given: Numbers a & b 2. Let a 2 a a 3. Let b 2 b b. 4. Let c 2 a 2 + b 2. 5. Let c c 2. 6. Return c. Figure 6: Pseudocode with a border in L A TEX output, no border in html output 10

\item Let $a^{2} \Rightarrow a \times a$ \item Let $b^{2} \Rightarrow b \times b$. \item Let $c^{2} \Rightarrow a^{2} + b^{2}$. \item Let $c \Rightarrow \sqrt{c^{2}}$. \item Return {\em c}. \end{enumerate} \end{center} \caption{pseudocode with a border in \LaTeX\ output, no border in {\sc html} output} \label{fig-pseudocod-boxed2} \end{figure} \ begin{latexonly} \floatstyle{plain} \restylefloat{figure} \ end{latexonly} Here are all the instructions about using this technique: 1. At the top of the document, put \usepackage{float}. Because it s only useful to L A TEX, I guess you could wrap it in a latexonly environment. 2. If you want all your figures to have borders, put a latexonly wrapper around \floatstyle{boxed} \restylefloat{figure} after the usepackage float. In fact, you could put all three commands on the same line & wrap them in latexonly. 3. If you just want certain figures to have borders, then in front of such a figure, put a latexonly wrapper around \floatstyle{boxed} \restylefloat{figure} in front of the figure & \floatstyle{plain} \restylefloat{figure} after the figure. A Other File Formats This document is available in multi-file HTML format at http://cybertiggyr.com/gene/dfx/. This document is available in Pointless Document Format (PDF) at http://cybertiggyr.com/gene/dfx/dfx. References [1] Patrick W. Daly. Graphics and colour with. Max-Planck-Institut Für Aeronomie, June 1998. http://tex.loria.fr/graph-pack/grf/grf.htm. [2] Michel Goossens and Frank Mittelbach. The L A TEX Companion. Addison Wesley Longman, Inc., 1993. ISBN 0201541998. [3] Michel Goossens and Sebastian Rahtz. The L A TEX Web Companion: Integrating TEX, html, and xml. Addison Wesley Longman, Inc., 1999. ISBN 020143317. 11

[4] Leslie Lamport. L A TEX: A Document Preparation System. Addison-Wesley Publishing Company, Inc., 1986. ISBN 0-201-15790-X. 12