Showing posts with label latex. Show all posts
Showing posts with label latex. Show all posts

Apr 10, 2012

Creating, Compressing and Cropping PDFs in Linux

Create PDFs from image files:

Tips from this website

tiff2ps *.tif | ps2pdf13 -sPAPERSIZE=letter - > test.pdf


Crop PDFs with Briss

In the directory where it is:

java -jar briss-0.0.13.jar


Compress bulky PDFs with ghostscript


gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=foo-compressed.pdf foo.pdf


What fonts are in your PDF?

To find if your pdf has embedded fonts and view their names, from the directory that the pdf is in, do:


pdffonts foo.pdf


For eg. mine has:


name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
CKAYMA+LMRoman12-Regular             Type 1C           yes yes no      62  0
NTPZFY+LMRoman12-Bold                Type 1C           yes yes no      64  0
YKKFPO+LMRoman12-Italic              Type 1C           yes yes no     104  0
HKNYHW+LMRoman10-Italic              Type 1C           yes yes no     142  0
JAICXS+LMMathItalic12-Regular        Type 1C           yes yes yes    155  0
DPVSWF+LMMathSymbols10-Regular       Type 1C           yes yes no     157  0
IIVZIQ+MSAM10                        Type 1C           yes yes no     178  0
QEUEKI+LMMathItalic8-Regular         Type 1C           yes yes no     188  0
SPUFLJ+LMMathExtension10-Regular     Type 1C           yes yes no     203  0
SVVDGN+LMRoman8-Regular              Type 1C           yes yes no     205  0
VDWDCM+LMSans10-Bold                 Type 1C           yes yes no     226  0
UARJSI+LMMathItalic10-Regular        Type 1C           yes yes no     228  0
DWAJMK+LMSans8-Regular               Type 1C           yes yes no     220  0
CPHBRB+LMSans10-Regular              Type 1C           yes yes no     222  0
QGJULQ+LMRoman10-Regular             Type 1C           yes yes no     224  0
CGHGWD+LMMathSymbols7-Regular        Type 1C           yes yes no     377  0
VEUSRU+LMSans9-Regular               Type 1C           yes yes no     359  0
CZNQDK+LMMathItalic5-Regular         Type 1C           yes yes no     371  0
QGJULQ+LMRoman10-Bold                Type 1C           yes yes no     363  0
MCEARB+LMMathSymbols9-Regular        Type 1C           yes yes no     361  0
CZNQDK+LMMathItalic7-Regular         Type 1C           yes yes no     365  0
AJGDMV+LMMathSymbols7-Bold           Type 1C           yes yes no     373  0
QGJULQ+LMRoman7-Regular              Type 1C           yes yes no     375  0
CGHGWD+LMMathSymbols10-Bold          Type 1C           yes yes no     367  0
QGJULQ+LMRoman7-Bold                 Type 1C           yes yes no     369  0

Mar 31, 2012

Getting longtable to flow into columns

I have incredibly long tables in the dissertation. Some of them are rather narrow and I can see that they can easily fit into two columns in landscape format. But longtable does not behave well with the two column format. I can see that many people want this to happen but are not close to a solution. I wonder if David Carlisle over at tex.stackexchange might be able to help me with this...

Before I go and post there, these are some of the existing threads with partial or no solutions at stackexchange:\

  1. Long table in two columns asked Jul 19 '11 at 13:04 by Petter
  2. Long table in two columns asked Dec 2 '10 at 10:56 by donatello
  3. Long table in two columns asked Dec 24 '10 at 13:41 by Freddie Witherden
  4. Long table in multiple columns asked Mar 19 '11 at 19:52 by Alan Munn
  5. Long table in two columns asked Feb 27 at 13:17 by Frg

An option suggested was to use the supertabular environment, but pdflatex has gone into an infinite processing loop that I soon need to kill. :/ There are some more options that I need to try out.
  • Use the tabbing environment
  • Use nested tabulars
  • supertabular with multicol

Okay, trials are over. This is a dead cause. Multicolumn-headings, headers and footnotes do not behave in the two column hacks. Instead, I have opted to use the pdfpages package and insert the preformatted longtables. Which brings me to another confounding issue... I know I can get the captions to go into the List of Tables with the addtolist= option but how do I get the inserted PDF tables to have auto-captions like regular tables? David Carlisle to the rescue again!

\usepackage{capt-of} 
\captionof{table}{a table caption}

Capt-of is splendid little package that includes captions outside float environments. And a hack to center the contents of a cell within a longtable column defined to be right aligned:


\begin{longtable}{>{\raggedright}p{4.2cm}rrrrr} 
\multicolumn{1}{c}{\footnotesize Contentof2ndCell}

 And no, \centering does not work for some reason.

Color in LaTeX

For the longest time, I avoided reading the xcolor manual. I finally opened it up yesterday and went to page 9. The simplicity of the whole package has finally dawned on me.

This is for all of us who are incredibly short on time but want precise colors in our documents! There are 16,777,216 colors that can be specified using a hexadecimal value.. Just use this form when specifying one of these colors:

somethingyouwantcolored=[HTML]{081D58}

will turn that thing into a dark navy blue.

Or you can define a name for the color:

\definecolor{darknavy}{HTML}{081D58}


and use this name instead

somethingyouwantcolored=darknavy


That's it! Black and white no more!

Mar 7, 2012

Complicated Longtables: Useful posts from Stackexchange

Longtables are full of quirks but tex.stackexchange makes things easier for troubled longtablers by bringing together some of the most helpful people to well... help out.

Complicated Longtables with:

Feb 6, 2012

Footnotes tricks in Longtable LaTeX environment

Example of various types of footnotes that can go into longtables.

For captions outside the longtable environment.

\textbf{Figure SA1.6b: Some table caption\footnote{Footnote content goes here}}\\

Drawbacks --> footnotes are placed in the footnote area and not right under the table.

A workaround to this is to remove the footnote rule just above the footnote to make it seem as if the footnote is just below the table.

\renewcommand\footnoterule{}


The modify the space between the footnotes and the footnotes and the body of the text

%\footins is the space between the text body and the footnotes:

\setlength{\skip\footins}{2cm}


The above two should make it seem as if the footnote is right under the table, when in fact it is outside the table. Hehe. Take that, latex devil.

Modify the space between the footnotes themselves.

%\footnotesep is the space between footnotes:

\setlength{\footnotesep}{0.5cm}

These nifty tricks came from stackoverflow

Dec 16, 2011

LaTeX for Landscaped Longtables

Header for landscaped tables with the mandatory 1.8" to 2.0" bound-thesis margin (nevermind the fact that no one actually knows if and whether these bound theses serve any use at all in this electronic age).

For the UofR thesis, the stuffy rules are:
Letter-sized page: 8.5 X 11"
Left margin: 1.8"
Right, top and left margins: 1.25"

In the geometry package, this means a printable total area of:
Horizontal: 8.5 - (1.8 + 1.25) = 5.45
Vertical: 11 - (1.25*2) = 8.5
total={5.45in,8.5in}



The table is a 3 column longtable multipage table with alternating color rows.


\documentclass[11pt]{article}
\usepackage[landscape, tmargin=1.8in, bmargin=1.25in, hmargin=1.25in,centering]{geometry}
\usepackage{longtable}
\usepackage[table]{xcolor}
\usepackage[none]{hyphenat}
\usepackage[T1]{fontenc}
\usepackage[default]{cantarell}
\usepackage{booktabs}
\definecolor{tableShade}{HTML}{F1F5FA}
\definecolor{tableShade2}{HTML}{ECF3FE}
\pagestyle{empty}
\renewcommand{\familydefault}{\sfdefault}
\renewcommand{\arraystretch}{1.3} %Sets row height
\setlength{\tabcolsep}{1.5pt} % Specifies column separation
\begin{document}
\begin{center}
\textbf{Title 1 goes here.}\\
\textbf{Title 2 goes here}\\\vspace{2em}
\textbf{Table x.1: Title of the table.}\\
\textbf{}\\
\end{center}
\setlength\LTleft{0in}
\setlength\LTright\fill
\rowcolors{1}{tableShade}{white}\centering %[commands]{row}{odd-row color}{even-row color}

\begin{longtable}{>{\raggedright}p{4cm}p{5cm}p{11cm}}
\midrule
\hiderowcolors
\textbf{Heading of 1st column} & \textbf{Heading of 2nd column}& \textbf{3rd Col Heading\protect\footnotemark[1] and heading continued}\\
\addlinespace[0.5em]
\midrule
\endhead
%\multicolumn{3}{c}[1]{Some footnote goes here x.x}\\
\midrule
\endfoot
\showrowcolors

% Table data goes here


\end{longtable}
\end{document}


-------------
Installing TeX packages on the fly:
yum install 'tex(epsfig.sty)'

Next project: Try and emulate the look and fee of this table. Font is Gotham and it's some baby blue color with white rules. The question is can I use the xcolor package and specify that color with hex codes?