25.6.11

How to color math symbols?


\textcolor from the xcolor package also works in mathmode, even if the name says otherwise. You can also use $ \color{} C^2 $. It sets the color for the rest of the current scope (group).
Examples:
\documentclass{article}
\usepackage{xcolor}
\begin{document}
$ \color{red} C^2 $
$ \color{yellow} A = \textcolor{blue}{B} \textcolor{red}{-} \textcolor{green} C $
\end{document}

24.6.11

Portrait caption (notes) for landscape figure and table

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[demo]{graphicx}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage[font=footnotesize]{subfig}
\usepackage{rotating}
\usepackage{blindtext}

\begin{document}
  \begin{figure}[!p]
    \centering
    \begin{sideways}
      \subfloat{%
        \includegraphics[width=60mm]{figurecode}
      }%
      \subfloat{%
        \rule{6cm}{4cm}   % replacement for missing table
      }%
    \end{sideways}
    \caption*{\blindtext}
  \end{figure}
\end{document}

How to Post LaTeX Equations in Blogger

I've gone through several approaches to post math equations on blogger. I found that the most effective and stable method is the one based on the CodeCogs server. Here's how it works:
  1. Go to the codecogs online LaTeX editor
  2. Type in your equations LaTeX
  3. Copy the HTML code that is generated at the bottom of the page
  4. Paste it in Blogger (either in the "Edit HTML" or "Compose views").
Here are the settings that I use:
  • image type: png
  • font: Sans Serif
  • fontsize: (10 pt) normal
  • resolution: 120 dpi
  • background: white
  • uncheck inline and compressed
  • choose: HTML (Edit) at the bottom (this allows you to click on the generated image and edit your equations! you'll have to copy the updated HTML though)
Voila!

23.6.11

How insert a PDF page into a Beamer presentation


Don't use pdfpages in beamer, they are not compatible. Include the PDF page using\includegraphics from the graphicx package like shown below.
\documentclass{beamer}
%\usepackage{epstopdf}
%\usepackage{xypdf}
%\usepackage{eso-pic} 
%\usepackage{everyshi} 
\usepackage{beamerthemesplit}
\usepackage{graphicx} 
\begin{document}
\frame[plain]{\includegraphics[page=61,width=\textwidth]{yourfile.pdf}}
\end{document}
You should put all material inside a frame macro or environment. The plain option will remove most of the material like header and footer.

The above code is for PDF images spanning the full slide. If you simply want to insert an image on a normal slide with some text, then you should use it like this. Note that thewidth=.6\textwidth makes the image width 60% of the text width (the frame or page width minus margins). Simply adjust the factor to your wishes. There is also height and\textheight, but the latter includes the slide title and subtitle which makes finding the correct value a little more difficult.
\documentclass{beamer}
\usepackage{beamerthemesplit}
\usepackage{graphicx} 
\begin{document}
\begin{frame}{Title}{Subtitle}
      Some text before

      \includegraphics[page=61,width=.6\textwidth]{yourfile.pdf}

      some text afterwards\end{frame}
\end{document}

Incluyendo «directamente» gráficos eps con pdflatex: el paquete epstopdf

Tomado de http://webs.um.es/mira/tex/ps4pdf.htm

Los documentos preparados para ser compilados con pdflatex soportan más formatos gráficos que los que se compilan con latex. Pero, lamentablemente, no permiten incluir ficheros en formato eps, ni código pstricks, ambos dependientes del lenguaje postscript por lo cual es necesario convertir estos gráficos a formatopdf. En otros apartados de esta lección hemos indicado la forma en que puede realizarse esta conversión.

Sería confortable poder realizar dicha conversión de forma automatizada mientras se compila el documento con TeX. Los dos apartados de esta sección se ocupan de esa posibilidad y aportan dos soluciones al problema. En esta primera, que es la más sencilla, se hace uso del paquete epstopdf para convertir al vuelo gráficos postscript bien creados. Para ello es necesario que el compilador pdflatex tenga activada la opción write18 que permite realizar llamadas a programas externos. Para activación de dicha opción aparece explicada en este documento. También es necesario que los programas Ghostscript estén acesibles desde cualquier sitio (es decir, estén incluídos en el path del sistema; si no sabe lo que eso significa, pregunte a alguien que le pueda ayudar).
La mecánica es muy simple: basta con incluir en el preámbulo del documento la línea
\usepackage{epstopdf}
y compilar con pdflatex
Ejercicio: Con los gráficos golfer.pdfmiktex.eps y setupwiz.eps cree un documento para compilar con pdflatex que produzca esta salida (grafico2.pdf); si necesita ayuda, el fichero  gráfico2.tex tiene el código que se ha utilizado.

Incluyendo «directamente» gráficos eps
y código pstricks con pdflatex: el sistema ps4pdf

La primera cuestión que tiene que plantearse antes de seguir leyendo este apartado y si le va a ser de utilidad. Y la respuesta es muy simple: sólo le será de utilidad si hace un uso intensivo de código pstricks mezclado con gráficos pdf.
El lenguaje pstricks utiliza comandos tipo LaTeX para realizar gráficos, posicionar objetos, etc. JpicEdit, entre otros, puede construir gráficos en ese formato. Se trata de un formato "sólo texto" que es interpretado por latex+dvips para construir un fichero postscript. Tal fichero postscript podría luego ser convertido a pdf para su incorporación a un documento LaTeX compilable con pdflatex.
Con ps4pdf pueden automatizarse todas esas tareas de suerte que es posible utilizar de forma simultánea gráficos eps, pdf, png, jpeg y codigo pstricks, sin que sean necesarios los procesos de conversión manual. El protocolo de utilización es muy simple:
  1. Cargar el paquete ps4pdf con \usepackage{ps4pdf}. Si el sistema no tiene instalado este paquete hay que instalarlo y también es necesario el paquete previewde LaTeX.
  2. Si se va a utilizar código pstricks es necesario cargar dicho paquete en el prámbulo del documento, pero como no es compatible con pdflatex es necesario hacerlo no en la forma usual, sino como argumento del comando \PSforPDF del siguiente modo \PSforPDF{\usepackage{pstricks}}.
  3. Cada vez que se incluye un gráfico eps con \includegraphics o bien código pstricks (generalmente mediante un \input) es necesario hacer que tales objetos aparezcan en el argumento de un comando \PSforPDF{ Argumento }. Así \PSforPDF{\includegraphics{Nombre.eps}} o \PSforPDF{\input{Nombre.pst}}son ejemplos de esta sintaxis.

En un sistema Linux para poder operar de forma confortable puede usarse el script ps4pdf ubicándolo en alguna carpeta accesible al path (típicamente /usr/local/bin) y en lugar de utilizar el clásico
  pdflatex NombreFichero
para compilar y producir una salida pdf, se utiliza
  ps4pdf NombreFichero
con el mismo propósito.
Aunque, teóricamente, debería ser lo mismo, con MS-Windows no hemos conseguido que nos funcione satisfactoriamente el sistema ps4pdf.
Ejercicio: Volvemos a utilizar aquí un gráfico golfer.pdf junto con un gráfico postscript miktex.eps y además código pstricks. El fichero fuente es gráfico3.tex y el resultado tras compilar con ps4pdf está es grafico3.pdf.

15.6.11

Using .eps Graphics Files with PDF output

For quite some time now, the graphicx package would automatically sort out which file types to use whenever it encounters\includegraphics{some_file}, where the extension of some_file isnot specified.

That is to say, if you are generating to a .dvi, the system would look forsome_file.eps. If you are generating to a .pdf, it looks for some_file.{pdf|jpg|png}.

But what if you want a .pdf and you work with .pdf, .jpg and .png graphic files, but suddenly you received a .eps graphics from your collaborator? (This actually happened to a lecturer at my university.)

Well, you could always convert it manually to a .pdf yourself with GhostScript or GIMP, of course. But now the process can be automated if you're using MikTeX 2.8 or TeXLive 2009, as highlighted by Rob Hyndman.

In MikTeX 2.8, use the epstopdf package together with graphicx, like so:

\documentclass{article}\usepackage{graphicx,epstopdf}\begin{document}\includegraphics[width=\textwidth]{some_file}\end{document}


If all you have is some_file.eps, it will be automatically converted to asome_file-eps-converted-to.pdf during the first time the LaTeX document is compiled and included in the final document output.

If you're using TeXLive 2009, you don't even have to load epstopdfexplicitly, but I say include it anyway, for portability's sake.