Oscar Flub

Could Typography have saved the Oscars?

The 2017 Oscar ceremony brought a strange twist that could only have made Steve Harvey smile. The most anticipated award for Best Picture was first given to the movie, La La Land. After a several minutes long acceptance speech by La La Land's producers, the true winner of the night -- Moonlight -- was eventually announced. So the biggest question is: how did this happen and could it have been prevented?

The mistake has been attributed to two PwC accountants handing the wrong envelope to Warren Beatty and Faye Dunaway. During the presentation, Beatty clearly looks confused. Dunaway, thinking that her 1967 Bonnie and Clyde co-star was pausing for dramatic effect, makes the announcement for La La Land. Beatty explains when he read the card, he paused because it read Emma Stone. This could have been prevented provided certain redundancies were put in place. As embarrassing and painful as this must have been for everyone involved, we can always count on the internet to put its own hilarious take on things.

The Mistakes the Academy Made

The mistake the two PwC accountants made is understandable. So too is the mistake made by both Dunaway and Beatty. Given how hectic and stressful it must be to work behind the scenes while ensuring that everything runs smoothly, it is a surprise this has not happened more often. If anyone must be blamed, it should be the Academy of Motion Picture Arts and Sciences.

A screengrab from the ABC News YouTube video of the event shows the cue card. The design gives us some clues on why this mishap may have happened. The cue card for Best Picture has the movie title in the same font size, weight, and style as the film's list of producers. This makes distinguishing these two fields difficult at a glance. Good typography should make this effortless. The award being given is also not noticeable at first glance because the words Best Picture is written in small, italicized font at the bottom. In fact, most likely, you probably missed it. At least we know which awards ceremony we are watching as the words The Oscars is prominent on top.

typography oscar flub
Poor typography may have contributed to the Oscar flub (Credit: ABC News).

Solving the Oscars' Cue Card Problem

Before we can propose a good card design, we need to establish some goals for the card. The card should, at a glance, tell the reader or announcer:

  1. The prize being awarded (red).
  2. The person, or film receiving the award (black).
  3. the ceremony (green).
typography oscar flub


In the case of the award being given to a person, the cue card should show the film that person worked on while for a film, it should list the people involved as well as their roles.

Next we figure out the level of importance each piece of information represents. A person reading the cue card will usually scan the card, their eyes focused on the middle of the card. They will announce the person who won the prize, followed by the film they were in. If the award is going to a film, that gets announced followed by the people who worked on the movie. These two are the most important pieces of information on the cue card. Next in importance is the prize being awarded. We can assume that the announcer will be told this before appearing on stage so this information exists for verification purposes. If this piece of information was more prominent on the cue card, either Dunaway or Beatty could have caught it and notified the PwC accountants. As odd as it sounds, the least important piece of information is the award ceremony. We all know which ceremony we are attending and this placement exists purely for branding purposes.

By varying a font's style, width, position, and weight, we can draw a reader's eye to what is important and what is not. We need to make the field highlighted in black the most prominent, followed by blue, then green, and lastly red. We also need to place this information in the center of the card. Steve Harvey's 2016 Miss Universe flub was also the result of bad design - the 2nd and 1st Runner Ups were placed on the left side of the cue card while the winner was placed on the bottom right. This poor placement meant that Harvey's hand was blocking the pageant's winner.

TikZ Code for an Oscars' Cue Card

We can code this in the LaTeX graphics package, TikZ. We want to put the information that an announcer needs to read in the center of the card. This is where their eyes will focus as they pick up the cue card to look at it. We can change the font's weight and size to further highlight and draw an announcer's eyes to what is important.

Oscars Typography
We can place the information an announcer needs to read near the center of the cue card (black and blue).

Our final card looks something like this. We are going to make the font for the person/film that won the largest and in bold. The font for the next piece of information will be smaller and not bold. The font for the award will be smaller still but still large enough that it can be seen and read easily. Last, the font for the ceremony will be the smallest size. The Academy will probably object to this but we aren't marketing a product where branding is important. We have an award ceremony to run.

Typography Oscars Layout
Where everything will go showing font size and weights.

Proposing a Layout

Now that we have established our goals and how they should be laid out, we can propose a card design. The font for the ceremony can be replaced by a logo and to add a little more emphasis for the award, we can put that in italics.

typogrpahy Oscars
A proposed cue card design for the Oscars

This should make things easier to read. The person announcing the award can tell, at a glance, the award they are supposed to read as well as who won that award. If they are not sure, the fact that they are announcing Best Picture can easily be seen above and the logo, while smaller, is noticeable to keep the Academy happy.

Going Further... Automation

We can go even further once we have everything in place. With LaTeX, we can create macros for each field and a new environment to contain it all. This will allow us to automate the process of creating cue cards.

Each new cuecard environment will typeset a new cuecard. There are packages that allow us to merge data from a CSV file in LaTeX, but we can also go for a fully automated solution, using something like Python or the R statistical language to query a database and generate the LaTeX code to typeset as many cuecards as you need. The LaTeX code can then be executed and the resulting cue cards printed.

Conclusion

We may not often think it but good typography matters. It makes reading effortless. It allows the reader to focus on what is needed and extract that information. The flub on Sunday night's ceremony was a result of poor typography and card design. A well-designed card means that either Dunaway or Beatty would have seen they were given the incorrect card and asked for a new one.

The Martian

Could LaTeX have saved "The Martian?"

In the 2015 sci-fi movie, The Martian, Mark Watney (Matt Damon) finds himself in the unenviable position of being stranded on Mars. One of the biggest problem our interpid astronaut faces, besides growing his own food to survive, is communicating with NASA. Mark needs to have complex astrophysical engineering conversations with nothing but still-frame camera from the late-90s. Luckily, the camera on the Mars Pathfinder spins. Mark can use degrees of arc to create an alphabet to encode transmissions, which will allow NASA to communicate with him.

The Martian ASCII Table

Mark finds an ASCII table on Beth Johanssen's (Kate Mara) laptop

There are 26 letters in the English alphabet which means each letter will be separated by a little under 14 degrees of arc. This will make it difficult for Mark to know exactly where NASA is pointing the camera. Mark needs to find a way to encode the data to make this task easier. One way of encoding this data is by using the American Standard Code for Information Interchange or ASCII; one of the widely used methods to represent text in computers. For this, Mark needs an ASCII table to translate the camera position into a usable alphabet. Luckily, he finds one on Beth Johanssen's (Kate Mara) laptop.

If Mark had LaTeX on his laptop, he won't need to rummage through his crewmate's personal belongings. With a simple command, he could pull up a PDF of an ASCII chart with ease. We know that much of the science portrayed on film and written in the book is realistic; the physics behind the radioisotope thermoelectric generator (RTG) can be seen in this Science vs. Hollywood article. This raises the question, could a LaTeX installation have saved mark Watney?

The ASCII wall chart

The ASCII wall chart is included in both MikTeX and TeX Live. This table was coded in TeX by Victor Eijkhout and appears to be based on a table seen in a 1972 printer manual. Eijkhout's version goes further as it includes the decimal, octal, and hexadecimal codes for all the ASCII characters.

The Martian ASCII Chart

The LaTeX ASCII Chart

Pulling up the chart is pretty simple. You just type the command:

texdoc --view ascii

in a command prompt or terminal and the chart will appear in your PDF viewer. Much easier than having to rummage through someone's junk.

How it works

As Mark mentions in the movie, he needs an alphabet to communicate with NASA. To transmit data, we need to encode it somehow. One way is to translate the direction Pathfinder's camera to represent a character. There are 26 letters in the alphabet, which means that each character will be separated by 13.8 degrees of arc. This is small and Mark could never be sure which letter the camera is pointing with certainty. To solve this problem, he turns to hexadecimals.

The hexadecimal number system uses sixteen distinct symbols, usually 0-9 and A-F, to represent numbers. If we include a question mark, we have seventeen characters in total. This leaves us with over 20 degrees of arc to work with. This is large enough for Mark to have a better idea which sign the camera is pointing at. Each ASCII character is made up of two hexadecimal digits; the camera has to point to two characters to encode one letter.

This begs the question, why include the question mark? There is an ASCII code (3F) for the question mark. The camera could point first at 3 and then F. Having fewer characters allows the letter signs to be spaced out more and make it easier to determine where the camera is pointing. It turns out that the difference in separation between 16 and 17 characters is not that much. In fact, it is less than two degrees - with 17 characters, the separation is approximately 21.2 degrees of arc but with 16 it is 22.5 degrees.

If we assume that NASA will ask lots of questions, the question mark symbol serves as an end of transmission character. Instead of pointing first at one character and then spinnning to point at another, the camera just points to one. This reduces the time to transmit that character. The time it takes for the camera to spin and point at these two characters is not worth the extra two degrees of arc.

Encoding Data to Communicate

The Martian Bandwidth

Tim Grimes (Nick Mohammed) notices that there is going to be a bandwidth problem on "The Martian."

It's not difficult to see that, while Mark's method of communication is ingenious, it is not without problems. As Tim Grimes (Nick Mohammed) points out, with a signal round trip of a little over thirty minutes and given the speed at which the camera rotates, this will be a very slow method of communication; the data transmission rate is pretty low.

The Martian Hacking Pathfinder

Mark modifies Pathfinder, entering the 20 pieces of hex code needed to patch Pathfinder into his Rover.

To solve this problem, NASA shows Mark how to hack Pathfinder's code so they can communicate by text message. This isn't too different from using Pathfinder's camera to decode a transmission. NASA will still use ASCII to encode a transmission but instead of encoding information as degrees of arc, they can send this information digitally, as a set of ones and zeroes. The computer on Mark's rover can then translate the digital transmission into readable text.

What can we learn from This?

The Martian LaTeX

Mark poses for a picture on "The Martian."

If you find yourself in the unenviable position of being stranded on Mars, a little foresight and planning helps. Make sure LaTeX is always installed on your NASA-issued laptop, as well as your personal machine. Admittedly, LaTeX won't have saved Mark Watney as the information he sought was hidden away on someone else's laptop, it would have made finding the ASCII table easier. But why won't you install LaTeX? It's awesome. Everyone should have it installed. Mark is a pretty resourceful guy. If he can make use of a radioisotope thermoelectric generator to save his life, he could have easily figured out how to use LaTeX.














clipboard package

Copy and Paste with the LaTeX clipboard package

The clipboard package by Ed­uardo C. Lourenço de Lima allows you to copy and paste commands across multiple documents. You may think this package seems unnecessary. After all, you can just ctrl-c and ctrl-v to your heart's content as you copy text from one document and paste into as many files you need. But what if you want to ensure that all the changes made in your main document is propagated across all the child documents? This is one area where this package shines.

Using the CTAN clipboard package

Copying into the Clipboard

The first thing you need to do is set up your main file, in this case Book.tex, to copy the things you need into a new clipboard. First, you need to name the clipbaord you are pasting to. We are calling the clipboard myclipboard, and we are going to copy a quote by Albert Eninstein (because why not?) into that clipboard.

Once we do this, we compile and voila. Compiling is an important step as it creates a .cpy file where the saved clipboard information is stored as a LaTeX macro. This can then be used by the package to find the necessary information to paste into other documents. A peek into the myclipboard.cpy looks something like:

Once we have compiled the LaTeX file, it looks like any other PDF. I have highlighted the copied text.

LaTeX clipboard

LaTeX code using the clipboard package to store a value in the clipboard.

Pasting from the Clipboard

Now that we have created a clipboard and copied some text into it, we can now paste that text into a new document. Our clipboard was called myclipboard and we will be copying the information stored in Einstein into our document.

We see how the LaTeX code pastes what we saved in Einstein into the our PDF. Again, I have highlighted the pasted text.

LaTeX clipboard

LaTeX code using the clipboard package to paste a value from the clipboard.

Looks pretty simple, doesn't it? Well, it is.

Uses for the clipboard package

There may not seem like there is much you can do with this package when a simple copy and paste will do but I argue differently. If your manuscripts contain a lot of quotations that you use frequently, you can create an initial LaTeX file that assembles all these quotes and saves them to the clipboard. This makes proofing a page of quotes relatively easy. These quotes can then be pasted into your manuscript. Of course, there are some disadvantages. All the LaTeX files need to be in the same folder, including the new clipboard file. Other than that, this is a pretty fun package to have in your LaTeX toolbox.














citing court cases

Citing court cases using the apacite package

The American Psychological Association (APA) has very strict guidelines on how manuscripts are written and formatted. These requirements are described in the Publication Manual of the American Psychological Association, also known as the APA Manual. To avoid confusion, APA follows the conventional format for legal citations which is a little different from what you will see in APA 6th. An important part of the APA style is formatting of citations and the references list which is described in some 50-plus pages of the APA manual.

While many writers do spend considerable time both learning and formatting their manuscripts, usually in Word, to meet APA's guidelines, LaTeX users are usually at ease and more focused on writing as LaTeX separates formatting from content; one of the advantages of LaTeX. Formatting and typesetting rules are handled by the apa6 package by Brian D. Beitzel. While this class file handles document formatting, it does not handle the formatting of citations and references. For that you need the apacite by Erik Meijer. As the format for citing a legal case is a little different, we can use the @literal type to get the desired format. To properly use this type it helps knowing the rules for citing legal cases.

Citing Legal Cases

Unlike the standard bibliography entry, you do not need to know an author's name to write a basic reference for a court decision but there is some information that is needed as APA follows the conventional format for legal citations. Most court decisions contain three basic elements:

  1. name of court case,
  2. source reporting the decision,
  3. court and date of decision.

Name of Court Case

citing court cases

The inside of the United States Supreme Court. In the photo are the nine chairs of the Supreme Court Justices.


A reference should start with the name of the case and in most cases this is the name of the parties involved. The word versus is abbreviated as "v." instead of the usual "vs." A well known case is Brown v. Board of Education. Here are a few other examples:

Lessard v. Schmidt Lessard vs. Schmidt
Gilliard v. Oswald Gilliard vs. Oswald
Durflinger v. Artiles Durflinger vs. Artiles
General Electric Co. v. Joiner General Electric Co. vs. Joiner

Reporting the Decision

citing court cases

The United States Reports, the official reporter of the Supreme Court of the United States. Taken by user Coolcaesar for the English Wikipedia at a public law library in San Jose, California on July 7, 2006.


Court decisions are bound in volumes called case reports. This makes the second element of our APA legal reference. Here things are quite different from what you typically see with the usual APA reference as it is more convenient to present information in the conventional format of legal citations. The decision is written as the volume, followed by the reporter, and then the first page number of the case.

BCSC 1316 BCSC 1316
239 Va. 312 Virginia Reports, vol. 239, p. 312
347 U.S. 483 United States Reports, vol. 347, p. 483

We see above how court decisions are reported. In the case of Brown v. Board of Education, putting the two elements together become

Brown v. Education, 347 U.S. 483

But our reference is not complete. We need to finish our decision with a date and possibly the court's geographical decision.

Court and Date of Decision

We generally expect the year to come after the author and, in the case for legal citations, the same should apply for a court case but it does not. For the final part of our reference, we place the geographical jurisdiction (if needed) and year in parentheses. This looks something like:

10th Cir. 1984 United States Court of Appeals for the Tenth Circuit, decided 1984
Tex. Ct. App. 1992 Texas Court of Appeals, decided 1992
Mich. 1999 Michigan Supreme Court, decided 1999

Putting it all together

We can put all that we learned together. Our reference starts with the court case followed by the decision and then the court that made the decision and the date the decision was made. As you notice, we cite also the reference in text with the case name in italics followed by the year.

Reference Textual Citation Parenthetical Citation
Lessard v. Schmidt, 349 F. Supp. 1078 (E.D. Wis. 1972) Lessard v. Schmidt (1972) (Lessard v. Schmidt, 1972)
General Electric Co. v. Joiner, 522 U.S. 136 (1997) General Electric Co. v. Joiner (1997) (General Electric Co. v. Joiner, 1997)
Brown v. Board of Educ., 347 U.S. 483 (1954) Brown v. Board of Educ., (1954) (Brown v. Board of Educ., 1954)

The apacite package

Now that we have a very basic idea how court cases are cited we can use this to cite cases using the apacite package. Unfortunately, the apacite package does not specifically support citing legal references but we can use the @literal type, as package author Meijer suggests, to get things looking right. You will need four fields in the literal type to get things looking right: text, key, firstkey, and year. As the citations are not generated automatically as we are accustomed, we need to use what we know above to help BibTeX along the way. Below we will look at some of the keys we need as well as how they are used.

The text key

The text key is used in the literal type and typesets the complete text as-is. This is the text that appear in our list of references.

The firstkey key

The firstkey key appears in all the BibTeX types used in the apacite package but more specifically, it is used as the author in parenthetical citations. In this case, it would be the name of the court case in italics.

The key key

This is another key that appears in all the BibTeX types but its use is somewhat different. The information here is what appears in the textual citation. Again, this is also going to be the court case. So why two separate keys to say basically the same thing? Well, the main reason has to do with the intricacies of APA. The APA manual requires abbreviations if certain titles are too long when making an in-text citation and this key allows you to do this. We don't need to abbreviate anything in this case so it remains the same as the first key which is the court case, again in italics.

The year key

This is possibly the most intuitive one of them all. We just put the year here... but wait! Court cases also have a geographical jurisdiction reported along with the year. Do we place that along with the year in the year key? No, we do not. We just put the year. We will see what to do with that geographical jurisdiction when we come to the text key below.

The text key

The text key is where we put everything as we would like it to appear in the list of references as we have seen above when discussing the requirements for legal cases citing APA.

The BibTeX File

Now we can put everything together. The text key is what appears in our bibliography. The firstkey key is the information that will appear in our parenthetical citation. The key key is what will appear in our textual citation.

The Manuscript

Here we use some of the natbib commands.

and get the final output:

citing court cases

An example of citing court cases in LaTeX and using the apacite package.

And there you have it. Citing court cases in APA using the apacite package is (relatively) simple.














Fill Rules

Fill Rules in TikZ

Filling shapes (or any path for that matter) in TikZ can be done with the \fill command. This requires very little thought on our part when it comes to filling simple shapes, e.g. circles or squares but it gets a little more complicated once we draw shapes with intersecting paths or holes. This is a difficult problem because we don't always know where the "inside" of a shape lies--this is not as simple as it sounds. To do this, we must understand the types of polygons there are as well as the rules for filling them with color.

Types of Polygons

We can divide polygons into two types: standard polygons and general polygons. Standard polygons are include circles, squares and triangles. These shapes have no holes and their paths don't self-intersect unlike general polygons.

Filling Shapes
The circle, square and triangle are basic polygons. Their paths do not intersect and the shape does not have a hole unlike the general polygon below.

Filling Shapes

There are two rules we can use to fill fhapes in TikZ:

  • Even-Odd Parity Rule
  • Non-zero Winding Rule

Both rules are algorithms that are used to determine whether a given point falls within an enclosed curve. To determine the "insideness" of a point, we draw a ray from the point we wish to determine to infinity in any direction. With the even-odd rule, we count the number of times the ray crosses a path segment. If the number is odd then the point lies on the inside of shape. If it is even then it lies on the outside.

Unlike the even-odd rule, the non-zero winding rule relies on knowing the stroke direction for each part the ray crosses. The number of intersections is scored and given a winding number. If the path is clockwise, or runs left to right, we subtract 1 from the score. If the path is counter-clockwise, or runs from right to left, we add one to the score. If the total winding number is zero then our point lies on the outside but if the winding number is not zero then the point lies on the inside. We will see how both rules differ and why.

Even-Odd Parity Rule

Fill Rules
We construct rays, both inside and outside, going through our shape of interest to determine if a point lies on the inside or ourside.

For a standard polygon, the shapes shown on top, it is easy to see where the outside lies but let's construct a few rays (shown in black) that lie outside and see what we get. For the circle, square, and triangle, the ray crosses the shape's path twice. This sum is even and we can conclude that the point lies on the outside of those shapes.

Now we construct some rays (shown in red) that lie on the inside. We see that they all cross the shape's path once. This makes the sum of path crossings odd and we conclude that the point lies on the inside of the shape.

But what happens with the general polygon below? We see that the black ray crosses the general polygon's path four times--an odd sum. This point lies on the outside of the shape. When we look at the red ray we see it crosses the shape's path once and we conclude that point lies on the inside.

Now let's look at the blue ray as it goes out from the hole. There is some doubt whether that point lies on the inside or outside of this shape but we can apply the even-odd rule. We see that the blue ray crosses the shape's path two times, an even number of times, which means the point lies on the outside of the shape and we don't color this area.

Fill Rules
Filling shapes with the Even-Odd Parity Rule

So we see how we can implement the even-odd rule in TikZ and how it works. But how exactly does the Non-Zero Winding Rule differ and will the results be the same? As you have probably guessed, the answer is no. After all, why have two different rules that do the exact same thing?

Non-Zero Winding Rule

Fill Rules
With the non-zero winding rule we need to consider the direction the path goes.

The non-zero winding rule is different from the even-odd rule in that we must consider the direction the path takes as the ray crosses it. We draw the direction of the winding path so we can determine whether a point lies on the inside or outside of a shape.

Fill Rules
We use our rays to determine whether a point lies on the inside or outside of a shape.

We do the same thing with the Even-Odd Parity Rule with one exception--if the path runs counter-clockwise as we cross it, we add one and subtract one if it runs clockwise.

For the circle, the first path crossing runs from left-to-right so we subtract one. As we continue our ray, the next crossing runs from right-to-left and we add one. The sum of our path crossings is zero and we conclude, like in the case of the even-odd rule, the point lies on the outside.

We see that for the circle, square, and triangle, the results are the same for the even-odd rule. Things are a little different for the general shape seen below. While the red and black rays yield the same result, the blue ray gives us something very different. The first crossing of the blue ray goes from left-to-right, we subtract one. The next crossing also goes from left-to-right, we again subtract one. The sum of our crossings is -2. The point lies on the inside and we fill the "hole" with color.

Fill Rules
We see the different effect of the Non-Zero Winding Rule on general polygons.

Path Matters

Fill Rules
In the case of general polygons, the even-odd parity rule (shown left) gives a different result from the non-zero winding rule (shown right).

We see the even-odd parity rule and the non-zero winding rule give different results for general polygons. This doesn't mean this is always the case. Path direction in the non-zero winding rule is the determining factor for the results we get.

We can create a general polygon with a hole where one shape lies inside the other and where their paths do not intersect. We can use TikZ code to specify the path directions of the innermost and outermost shapes. On the left, the outermost square's path curves around in a clockwise direction but its innermost square curls in a counterclockwise direction. We see with the general polygon on the right, both the inner and outer squares both curl clockwise.

Fill Rules
We can construct a general polygon with non-continuous paths. The difference is that the left inner square's path is counter-clockwise while the one on the right rotates in the clockwise direction.

We know that the even-odd rule will leave the hole unfilled in both cases as we are just counting path crossings but if we were to use the non-zero rule, on both shapes? We see that the outcome depends on path direction. The shape on the left with a counter-clockwise inner square produces the same result as the even-odd rule but the hole is filled when the inner path goes in a clockwise direction.

Fill Rules
The non-zero winding rule can produce different results for the same shape. This is due to the path differences of the inner rectangle.

Conclusion

Filling shapes with color doesn't have to be a complex operation if you understand the two fill rules and how they work. Generally, the even-odd parity rule won't fill a hole but whether the non-zero winding rule does depends on the path direction of the hole. Once we understand that, drawing and coloring shapes in TikZ becomes very easy.

Aligning Numbers in siunitx

The use of tables to communicate quantitative information is common in both academia and business but effective design sometimes eludes us. Readers must, at a glance, be able to get the information they need from the data you present. Fortunately, the tools for effective table design exist in LaTeX at least, if you know what you are doing. We are going to look at some simple ways to align numbers using the siunitx package.

The Table

We have the following table. While it is fairly presentable, we can't help but wonder can we do better? Yes, we see the numbers are fairly aligned in most cases but things look a little out of place where there are negative numbers.

Aligining numbers in siunitx
The numbers in the table are centered but the decimals are not aligned. We also need to italicize some of the numbers to highlight important data.

The code for our table looks something like this:

Though we can probably leave this table as is, we need to make some changes. Some of the numbers also need to be italicized to highlight some important data. This should be simple as we see below.

Aligining numbers in siunitx
Some of the numbers have been italicized but this throws off some of the decimal alignment.

So the question is, how can we make our table look better?

The siunitx package

The siunitx package not only allows authors to typeset quantities with ease and in a consistent way but also provides the tools to typeset tables. The package introduces another column type--the S column--to control alignment. We can then use the package's number parser to align our numbers. We are also going to use the [table-format=2.6] to tell the package something about our number. In our case, the number 2.6 tells the parser that the number has two integer digits and six decimal places. There are other options we can use for our S-columns that are outlined in the siunitx manual.

Aligning numbers in siunitx
The siunitx package allows for decimal alignment rather just centering numbers and hoping for the best.

which we can see from the code below.

Wait a second. Didn't we just say that the S-column allows us to align numbers? Well, it seems that some of the italicized numbers are no longer aligned and the dash is no longer centered. If anything, the siunitx package has made things worse! Does this mean we should go back to what we had before?

Fixing Decimal Alignment in siunitx

The problem we face is that the siunitx package's math parser doesn't see the italicized numbers as numbers but rather as text. It's the reason why the dash in the table is left aligned. Let's focus on each problem instead of worrying about both at the same time. Instead of the \textit macros, we will use \mathit to italicize numbers. This will tell siunitx's math parser its dealing with a number and not a word. Now our fix looks like:

Aligning numbers in siunitx
The \mathit macro tells the siunitx package that it is dealing with a number and not a word.


and the code looks something like:

There, that looks much better but we still have to deal with the left aligned dash. Now we must tell the siunitx parser to center the dash. We can do this by enclosing the cell's contents in curly braces:

aligning numbers in siunitx
By enclosing the \multirow command in curly braces we tell the sinuitx package's parser to center the text.


and our code looks like:

Conclusion

And there you have it. By using the siunitx package you can easily align numbers and text in your tables. Now your tables look great you can get back to stress-free writing.

past-tableur filled

Using the pas-tableur style for spreadsheets in LaTeX

One of LaTeX's strengths is its ability to typeset publication quality tables using the booktabs but sometimes we need something that look like a spreadsheet. There are several solutions to this problem. If we are working in Excel, we can, for example, select the necessary cells of interest and create an image to be inserted into our document. There are some problems with this solution. As we are all too aware, things change during the course of writing and if our spreadsheet changes, we must go through the process of recreating our image and inserting the new image into our LaTeX code.

Though it takes some time and effort (in the beginning) there are several good reasons to rendering something that looks like a spreadsheet in code. For one, we can easily see the code to make sure everything is correct before we compile but the biggest advantage is that any changes can be made easily. We don't have to fire up Excel (shudder) and so save time during the editing process. As ideal as this solution is, there is one problem. A huge one. It takes some planning and prep for it to move smoothly.

To get an idea of how you can do this you can take a look at the "Typesetting a table to look like a spreadsheet" discussion on StackExchange. It's not difficult and we see one solution using the array and colortbl packages and another in TikZ. Of course, there is a problem of utility. These solutions are fine if you just need to show one spreadsheet image. What if you have many spreadsheets, for example, in the case where you're writing a book? How can you make this easier? You can use the TikZ pas-tableur package by Stéphane Pas­quet.

Getting Started

Though the pas-tableur package documentation is written in French, the package is easy to utilize. To start you just need to load the package:

Now you can start drawing your spreadsheets

Drawing a Spreadsheet

The tableur command automatically creates a spreadsheet with the tableur command. As this uses the TikZ package, the command must be enclosed within the tikzpicture environment. The command syntax is:

To create a 3 by 4 spreadsheet, we use:

which looks like

spreadsheet

A pas-tableur spreadsheet with no options defined.

Changing colors up

This isn't bad as things go but what if you need to customize things a bit? Turns out this is simple. You can define these options in the preamble.

The above are the default options. What is we wanted to change the color of the top part of the header to yellow?

which gives us the output:

pas-tableur spreadsheet

A pas-tableur spreadsheey with the top part of the header colored in yellow.


and as Bermuda Sand is a wonderful color, we add the command:

and we get:
pas-tableur yellow

A pas-tableur spreadsheet with the top part of the header colored in yellow and the bottom part colored in Bermuda Sand.


Now that you're adjusted the header colors, what if you needed to change the cell lines to a nice dark golden color?

which looks like:
pas-tableur spreadsheet

A pas-tableur spreadsheet with the color of the cell lines changed.


Changing cell size

Now that we have had fun with changing the colors of our spreadsheet, what if we just wanted to change the cell width and height? For that we turn to the colminwidth and lineminheight commands.

Our extra long spreadsheet looks like this:

pas-tableur spreadsheet

Image showing a pas-tableur spreadsheet with a long cell width.


We can do the same thing for the cell height:

which looks like:
pas-tableur tall cells

A pas-tableur spreadsheet with extra tall cells


Filling the cells

Drawing empty spreadsheets are fun but generally we fill spreadsheets with text and formulas. This can be done with the celtxr command.

Now we can fill our spreadsheet:

which looks like:

past-tableur filled

The pas-tableur spreadsheet has been filled with text and formulas.


Selecting and Highlighting Cells

Selecting a Single Cell

You may need to select or highlight cells to illustrate your point. For that, we turn to the selecCell command.

So if we wanted to select the C2 cell of our spreadsheet:

Selecting Multiple Cells

Sometimes we need to highlight, not one, but a group of cells. For that we turn to the multiSelec command:

So if we wanted to highlight B2 to D4 in our spreadsheet:

which looks like:

pas-tableur spreadsheet

Here we can see the B2 and D4 cells highlighted.


Changing the colors

But what if you wanted to change the color of the highlighted headers? For that we define the blueSelecCellTop and the blueSelecCellBottom colors in the preamble:

which looks like:

pas-tableur spreadsheet

Here we change the colors of the top and bottom parts of the highlighted cells.


Conclusion

The pas-tableur package is an easy to use LaTeX package for generating spreadsheet images. Of course, you can use your favorite spreadsheet, capture it as an image and integrate it into your document but the package offers some advantages. As everything is generated in LaTeX code, you can add spreadsheets and make edits easily--the process becomes a part of your writing which is something we all love about LaTeX.

I found the package easy to use and understand and would recommend it to anyone who needs to generate spreadsheet images into their document.














Quotation Marks and the LaTeX dirtytalk package

When typesetting documents in LaTeX, users must be aware of the rules regarding quotations for different languages. In the English language, there are differences between the primary and secondary quotation marks used in US and UK English as we can see in our CTAN Quotation Packages in LaTeX blog article. To make things even more interesting, while the German language has its own set of quotation marks („ quote”) used in everyday writing, some modern printed books use a reverse order French quotation marks or « quillemets ».

While babel package does allow for the typesetting of quotation marks across different languages, see table below, and though it is possible to use either the appropriate key combination or TeX code, typing quotes can be cumbersome depending on the language.

Table of international quotation marks and their babel key combinations and LaTeX codes
Language Quotation Marks Key Combination LaTeX Code
 Primary  Secondary Primary  Secondary  Primary  Secondary
 English (UK)  ‘…’  “…” …' …''
 English (US)   “…”  ‘…’ …''  …'
 German  „…”  ‚…’ "…"'  \glqq…\grqq  \glq…\grq
 French  «…»  «…» "‹…"›  \flqq…\frqq \flqq…\frqq
 Danish  »…«  ›…‹  \frqq…\flqq  \frq…\flq
 Lithuanian  „…” "…"'  \glqq…\grqq
 Russian  «…»  „…” "‹…"›  "…"'  \flqq…\frqq  \glqq…\grqq
 Ukrainian  «…»  \flqq…\frqq

Typesetting Quotation Marks

The dirtytalk package allows easier typesetting of quotations using the command \say{something}. The appropriate quotation marks are inserted by the macro and the package also allows for nested quotations. This makes entering quotations much easier.

How quotation glyphs are used can be loaded in the package options. As we can see from the above table, an English writer from the US might enter:

For example, we can use:

Which gives us:

"What did you mean when you said 'that' computer?"

For UK English, we load the options:

Which gives us:

'What did you mean when you said "that" computer?'

Being aware and manually tracking these typographic rules for quotations can make proofreading code difficult if we are just looking at LaTeX code. In that regard the dirtytalk package can help.

The French, Danish and Russian Languages

Entering quotation marks in English is easy but what if you working in another language, say French or Danish? Both languages make use of guillemets or « angle quotes ». The babel package uses the \flqq and the \frqq commands to typeset these glyphs but entering them can be a tad bit inconvenient.

To get our French quotations, we set the options as follows:

While there are single quillemets, ‹ and ›, that do exist in the babel package, they aren't typically used and just entering single angle brackets or the "greater than'' and "less than'' sign, < and > respectively, doesn't quite achieve the intended results.

In the Danish language, the quillemets are reversed while in the Russian language, there is a mix of guillemets and the German `low 9'' („) quotation marks.

In the Russian language, we can set our dirtytalk options to look like:

Advantages and Disadvantages

The dirtytalk package makes the typesetting of quotations in any language easier but there are some limitations. For one, it only allows for one set of nested quotations and anything beyond will take some user modification of the package. The second disadvantage to the package is that it can only handle quotations in one language. For documents that contain more than one language there are other options but for what it does, the dirtytalk package works nicely.














CTAN Quotation Packages in LaTeX

[latexpage]

In LaTeX, typing quotation marks in English (either US or UK) is easy but doing so consistently and across different languages is problematic. The problem stems from the array of different marks each language uses. We can see in table \ref{tab:table1} the different marks across languages. To ensure uniform typography, writers must be aware of and pay attention to various language rules, e.g. the primary and secondary quotation marks are swapped in UK and US English.

Table of primary and secondary quotation marks for different languages
Language Primary Secondary
English(UK) '…'
English(US) '…'
Danish »…« >…<
Lithuanian „…” No secondary quotes
French «…» «…»
German „…” ‚…’
Russian «…» „…”
Ukrainian «…» No Secondary Quotes

To make life easier, there are several packages on the CTAN database that makes the entering of quotation marks easier and efficient.

The dirtytalk Package

Manual

ftp://sunsite.icm.edu.pl/pub/CTAN/macros/latex/contrib/dirtytalk/dirtytalk.pdf

Description:

This is a very small LaTeX package that runs just 51 lines with just one command: \say. It can be loaded in the preamble: \usepackage{dirtytalk} and supports one nested quotation thus allowing for consistent primary and secondary application of quotation marks. Users can also redefine the quotation marks:

Here we can see the code for German quotations.

Pros

  • Easy of use, only one command.
  • Supports nested quotations.

Cons

  • Only one nested quotation. No rule for adding more nested quotations without modifying package source code.
  • No support for babel or polyglossia for quotes glyphes.

To learn more, read our dirtytalk article.

The csquotes Package

Manual

ftp://ftp.gust.org.pl/TeX/macros/latex/contrib/csquotes/csquotes.pdf

Description

A fairly large package with advanced facilities for inline and display quotations. Supports a wide-range of commands, environments and user-definable quotes. Quotes can be adjusted to the current languages. Autostyle can be turned by autostyle=true in the options. There are vast variety of commands to insert quotes: inline, quotes with sources, block-quotes with the support of changing language.

Pros

  • Usage of babel and polyglossia packages for quotations marks.
  • Custom number of nested quotes.
  • Multilingual documents: options to set language for arbitrary quote.

Cons

  • Vast number of options and commands --- too complex for most tasks.

The epigraph Package

Manual

ftp://ftp.tpnet.pl/pub/CTAN/macros/latex/contrib/epigraph/epigraph.pdf

Description

Another large package with vast of options to typeset the epigraphs and epigraphs lists. Provides commands for typesetting a single epigraph: \epigraph, and an epigraphs for typesetting a list of epigraphs. Can be typeset at either left, right and center of the typeblock.

Pros

  • Easy typeset of quotes and quotes list.
  • Many options for customization.
  • Can be used with bibliography.

Cons

  • Looks like it being frozen - long time without update.

The fancychapters Package

Manual

Only exists as LaTeX source code
ftp://sunsite.icm.edu.pl/pub/CTAN/macros/latex209/contrib/misc/fancychapters.sty

Description

The package adds two new commands:

  • \Chapter{«quote»}{«title»}
  • \Chapter{«quote»}[«abbrev»]{«title»}

Simple package to print fancy chapter headings.

Pros

  • Automatic calculation of width to print fancy quotation and chapter name.

Cons

  • Can be used only with book and report documentstyles.
  • Works only for chapters: support for custom document parts like the empheq package.

The quotchap Package

Manual

ftp://ftp.gust.org.pl/TeX/macros/latex/contrib/quotchap/quotchap.pdf

Description

A very small package of only only 87 lines for typesetting quotations after the \chapter command by redefining both the \chapter macro and its starred version.

Pros

  • Better than the fancychapter package as it is newer and more customizable.
  • Color and fonts can be customized easily.

Cons

  • Works only with book and report classes.

The epigram Package

Manual (in source code)

No official manual exists other than the LaTeX source code file.
ftp://ftp.tpnet.pl/pub/CTAN/macros/generic/misc/epigram.tex

Description

A package that provides an \epigram command to typeset epigrams that is both easy and simple to use. It is so small that the entire code can be shown here:

Pros

  • So simple that it's hard to break.

Cons

  • There are few (almost no) options for customization.
  • Looks like nothing more than the simple example of package.

Conclusion

  • As we can see, there are a number of interesting and useful CTAN packages for typesetting quotations, quotes and heading for chapters.If you need to just typeset simple quotes or quotations the best way is the dirtytalk package for it simplicity. This can be wrapped it in the flushleft environment.
  • For simple chapter headings we can use the epigram or the fancychapters packages. The epigraph can also be used for typesetting list of quotes.
  • The best package for typesetting quotes is the csquotes package as there is support for almost everything from automatic quotes symbols detection, inline-, block- quotes, vast options for customization, multilingual support and much more. This package is large, making it more suitable for large documents with many languages.