ConTeXt es un paquete de macros de propósito general para TeX, desarrollado por Hans Hagen; para algunos es una alternativa seria a LaTeX. Ver detalles en http://www.pragma-ade.com/. Se puede encontrar una útil introducción en http://berend.gameren.nl/tex/, en el documento «LaTeX in proper ConTeXt». TeXShop soporta ConTeXt.
MetaPost es un sistema similar a MetaFont que ha sido desarrollado por John Hobby; obtiene como salida archivos postscript y pdf. Se puede usar para producir ilustraciones en PostScript. Ver detalles en http://cm.bell-labs.com/who/hobby/MetaPost.html. Además, se pueden encontrar interesantes ejemplos elaborados con MetaPost en muchos sitios: ver, por ejemplo, http://www.cs.ucc.ie/~dongen/mpost/mpost.html. TeXShop soporta MetaPost.
He aquí un ejemplo de un archivo MetaPost:
- prologues:=2;
- color yellow; yellow = green + red;
- def star (expr size, n, pos, color)=
- for a=0 step 360/n until 360:
- draw (origin -- (size/2,0))
- rotatedaround (origin, a)
- shifted pos withcolor color;
- endfor ;
- enddef;
- beginfig(-1);
- pickup pencircle scaled 2mm; star (2cm,5,origin,red);
- endfig;
- beginfig(2);
- pickup pencircle scaled 2mm; star (2cm,7,origin,yellow);
- endfig;
- beginfig(3);
- pickup pencircle scaled 2mm; star (2cm,11,origin,green);
- endfig;
- beginfig(4);
- pickup pencircle scaled 2mm; star (2cm,13,origin,blue);
- endfig;
- end
Supón que este archivo se llama «metademo.mp». Al procesarlo con MetaPost, generará cuatro archivos postscript diferentes, llamados metademo.1, metademo.2, metademo.3, metademo.4. Estos nombres están determinados por el parámetro numérico de «beginfig()». Si este número no es negativo, como beginfig(0) o beginfig(10), el archivo resultante se llamará metademo.0 o metademo.10. Si este número es negativo, como beginfig(-10), el archivo resultante se llamará metademo.ps, sobreescribiendo cualquier archivo metademo.ps creado previamente.
En su configuración predeterminada, TeXShop asume que uno de los números es cero. TeXShop llama al script epstopdf para convertir cada archivo postscript en un archivo pdf. Finalmente, el script renombra el archivo pdf marcado como número cero, y le pone el nombre del código con extensión pdf, por ejemplo, metademo.pdf, y muestra este archivo en la ventana de los pdf.
Cuando estés editando un archivo MetaPost, cambia el número de la figura que estés editando de positivo a cero. TeXShop mostrará esta figura como si estuviera siendo depurada (‘debugged’). Cuando estés satisfecho con la figura, vuelve a poner el número positivo, y cambia el número de otra figura de positivo a cero.
Una vez que los archivos MetaPost están creados, pueden usarse y visualizarse como cualquier otra ilustración. Se puede usar Pdflatex si las ilustraciones están ya en formato pdf, o TeX y Ghostscript para incluir ilustraciones postscript sin convertir. Por ejemplo, podremos ver las cuatro ilustraciones creadas con el código MetaPost anterior compilando el siguiente archivo mediante TeX y Ghostscript:
- \documentclass[11pt] {article}
- \usepackage{graphicx}
- \begin{document}
- Here are some illustrations.
- \vspace{.2in}
- \includegraphics[width=1cm]{metademo.1}
- \hfill
- \includegraphics[width=1cm]{metademo.2}
- \hfill
- \includegraphics[width=1cm]{metademo.3}
- \hfill
- \includegraphics[width=1cm]{metademo.4}
- \hfill
- \end{document}
Usando el paquete mfpic, también podemos incluir código Metapot directamente en un archivo LaTeX. Al usar este método, las preferencias para Metapost, que se controlan en el diálogo de Preferencias, se deben poner como «mpost», no como «mptopdf»; esto permite que MetaPost se ejecute directamente cuando seleccionamos el motor Metapost. Un documento que contenga código Metapost se compone primero con pdflatex o latex, y así se crea un archivo con código mp con todas las ilustraciones del documento. Y este archivo se compila con Metapost. Finalmente, el documento se compone de nuevo con pdflatex o latex, y así se muestran las ilustraciones resultantes.
A continuación mostramos un ejemplo creado por Claus Gerhardt. Guarda este ejemplo como «MetaPostTest». Observa la línea
«\opengraphsfile{MetaPostTest}» en el código fuente. El paquete mfpic permite cualquier nombre para este archivo gráfico pero, si queremos usar el siguiente procedimiento con TeXShop, su nombre debe coincidir con el nombre del documento.
Compón el documento una vez, vuelve a MetaPost y compón de nuevo, y por último, compón con LaTeX una vez más.
En el primer y tercer paso de este proceso se puede usar tanto pdflatex como latex + ghostscript.
- % This example is a shortened version of an example provided by
- % Claus Gerhardt.
- \documentclass[11pt]{article}
- \usepackage[metapost]{mfpic}
- \usepackage{amsmath}
- \opengraphsfile{MetaPostTest}
- \title{Brief Article}
- \author{The Author}
- \begin{document}
- \maketitle
- \begin{mfpic}[20]{-0.5}{11}{-0.5}{11}
- {\drawcolor{red}\function{0,10,0.05}{10-x}}
- {\drawcolor{blue}\function{0.99,10,0.05}{10/x}}
- {\drawcolor{green}\dashed\lines{(0.0,4),(10,4)}}
- \tlabelcolor{black}
- \drawcolor{black}\ymarks[4pt]{4}
- \headcolor{black}
- \drawcolor{2*black}\axes
- \tlabel{(4,6.5)}{$P_{\negthickspace c}$}
- \tlabel{(6,6.5)}{$P_{c}$}
- \tlabel(5,3.5){$A$}
- \tlabel{(-.6,3.9)}{$4$}
- \end{mfpic}
- \begin{center}
- \begin{mfpic}[15]{-2.2}{5}{-2.2}{2.2}
- \store{a}{\circle{(0,0),2}}
- \store{b}{\circle{(2 *sqrt 2,0),2}}
- \store{c}{\arc[p]{(0,0),-45,45,2}}
- \gfill[0.7white]\lclosed\mfobj{a}
- \gfill[white]\lclosed\mfobj{b}
- \draw\mfobj{a}\draw\mfobj{b}
- \tlabel(-1,-0.3){ $A$ }
- \tlabel(3,-0.3){ $B$ }
- \end{mfpic}
- \end{center}
- \closegraphsfile
- \end{document}
El siguiente ejemplo, de nuevo proporcionado
por Claus Gerhardt, muestra la potencia de MetaPost.
- % This example was provided by Claus Gerhardt
- % Most of the figures and the text are taken from G.'s book
- % "Analysis I" published by International Press, Boston,
- % which will appear at the beginning of 2004.
- \documentclass[11pt]{amsart}
- \usepackage[metapost]{mfpic}
- \usepackage{amsmath}
- \usepackage{amsthm}
- \RequirePackage{amssymb}
- \RequirePackage[mathscr]{eucal}
- \opengraphsfile{MetaPostTest}
- \DeclareMathOperator*{\Au}{\forall}
- \DeclareMathOperator*{\Eu}{\exists}
- \newcommand{\msc}{\protect\mathscr}
- \newcommand\su{\subset}
- \newcommand{\pri}[1]{#1^\prime}
- \newcommand{\tit}[1]{\textit{\ignorespaces #1\ignorespaces}}
- \newcommand{\Cc}{{\protect\mathbb C}}
- \newcommand\ra{\rightarrow}
- \newcommand{\abs}[1]{\lvert#1\rvert}
- \newcommand{\fv}[2]{#1\hspace{0pt}_{|_{#2}}}
- \newcommand{\set}[2]{\{\,#1\colon #2\,\}}
- \newcommand\inn[1]{{\overset{\msp[9]\circ}{#1}}}
- \newcommand{\msp}[1][1]{\mspace{#1mu}}
- \newcommand{\Si}{\varSigma}
- \theoremstyle{remark}
- \newtheorem*{definition}{\bf Definition}
- \theoremstyle{theorem}
- \newtheorem*{theorem}{Theorem}
- \title{An Example of how to use mfpic}
- %\author{The Author}
- \begin{document}
- \maketitle
- \thispagestyle{empty}
- \bigskip
- \begin{mfpic}[20]{-0.5}{11}{-0.5}{11}
- {\drawcolor{red}\function{0,10,0.05}{10-x}}
- {\drawcolor{blue}\function{0.99,10,0.05}{10/x}}
- {\drawcolor{green}\dashed\lines{(0.0,4),(10,4)}}
- \tlabelcolor{black}
- \drawcolor{black}\ymarks[4pt]{4}
- \headcolor{black}
- \drawcolor{2*black}\axes
- \tlabel{(4,6.5)}{$P_{\negthickspace c}$}
- \tlabel(5,3.5){$A$}
- \tlabel{(-.6,3.9)}{$4$}
- \end{mfpic}
- \bigskip
- \begin{definition}
- Let $E,\pri E$ be metric spaces and $f:E\rightarrow \pri E$ a map. $f$ is called \tit{continuous} at $x_0\in E$ if
- \begin{equation}\notag
- \Au_{\pri U\in \msc U(f(x_0))}\; \Eu_{U\in \msc U(x_0)}\quad f(U)\su \pri U.
- \end{equation}
- $f$ is called continuous in $E$ if $f$ is continuous at every point of $E$.
- \end{definition}
- \bigskip
- \begin{center}
- \begin{mfpic}[15]{-4.2}{16}{-4.2}{4.2}
- \store{R}{\rect{(-4,-4),(4,4)}}
- \store{U}{\cyclic[.75]{(-2,-2),(0,-1.5),(2,-2.4),(1.8,2),(0.5,1.8),(-2.3,1.7)}}
- \store{FU}{\shiftpath{(12,0)}\cyclic[.75]{(-1.5,-1.5),(0,-1.2),(2,-1.7),(1.8,2),(0,1.6),(-2,1)}}
- \store{UU}{\shiftpath{(12,0)}\cyclic[.75]{(-2.8,-3),(0,-2),(3,-2.4),(2.8,2.8),(0.5,2.4),(-2.9,1.7)}}
- \gfill[0.6white]\mfobj{U}
- \gfill[0.8white]\mfobj{UU}
- \gfill[0.6white]\mfobj{FU}
- \draw\mfobj{U}
- \draw\mfobj{UU}
- \draw\mfobj{R}
- \draw\mfobj{FU}
- \arrow\curve[1]{(3,2),(6,3),(9,2)}
- \point{(0,0),(12,0)}
- \shiftpath{(12,0)}\mfobj{R}
- \tlabel[tc](0,3.5){$E$}
- \tlabel[tc](12,3.5){$E'$}
- \tlabel[tl](-2,0){$U$}
- \tlabel[tl](10.1,1){$f(U)$}
- \tlabel[tl](9,-1){$U'$}
- \tlabel[tl](0.1,0){ $x_0$ }
- \tlabel[tl](12.1,0){ $f(x_0)$ }
- \tlabel[tc](6.1,3.8){$f$}
- \end{mfpic}
- \end{center}
- \noindent
- \parbox[c]{7.51cm}
- {The picture on the right shows the intersection of two
- sets $A$ and $B$. Notice that this intersection consists of
- all points which belong to both sets.}
- \hfill
- \begin{minipage}{40mm}
- \begin{mfpic}[15]{-2.2}{5}{-2.2}{2.2}
- \store{a}{\circle{(0,0),2}}
- \store{b}{\circle{(2 *sqrt 2,0),2}}
- \store{c}{\arc[p]{(0,0),-45,45,2}}
- \store{de}{ \arc[p]{(2 *sqrt 2,0),135,225,2}}
- \store{dd}{\lclosed\connect\mfobj{de}\mfobj{c}\endconnect}
- \gfill[0.7white]\mfobj{dd}
- \draw\mfobj{a}\draw\mfobj{b}
- \tlabel(-1,-0.3){ $A$ }
- \tlabel(3,-0.3){ $B$ }
- \end{mfpic}
- \end{minipage}
- \bigskip
- \begin{definition}[Complex logarithm\index{complex logarithm}]
- The \tit{complex logarithm}, $\log: \Cc^* \ra S_l$, is defined by
- \begin{equation}\notag
- \log z=\log\abs z+i\arg_lz.
- \end{equation}
- It is the inverse of $\fv\exp{S_l}$, the so-called \tit{ main branch}
- of the exponential function.
- \end{definition}
- The region of discontinuity
- is now the axis
- $\set{z\in\Cc^*}{\arg z=\pi}$. Thus, the exponential function
- is not only bijective in the
- open strip
- $\inn S_l$,
- but also a differentiable homeomorphism onto
- $\Si=\set{z\in\Cc^*}{\arg z\neq \pi}$ with
- $\pri\exp z=\exp z\neq 0$, and therefore, in view of the previous theorem, we may conclude
- \begin{theorem}
- The complex logarithm is infinitely often differentiable in $\Si$
- and
- $\pri\log z=\frac{1}{z}$.
- \end{theorem}
- \begin{mfpic}[15]{0}{20}{-2.5}{3}
- \gfill[0.6white]\rect{(12,-2),(20,2)}
- \gfill[0.6white]\circle{(4,0),2}
- \arrow[l 5pt]\lines{(4,0),(8,0)}
- \arrow[l 5pt]\lines{(4,-2.5),(4,3)}
- \arrow[l 5pt]\lines{(12,0),(20,0)}
- \gfill[white]\circle{(4,0),0.05}
- \arrow\curve[1]{(7,2.5),(10,3.5),(13,2.5)}
- \penwd{1pt}
- \draw[white]\lines{(0,0),(4,0)}
- \penwd{0.5pt}
- \arrow[l 5pt]\lines{(16,-2.5),(16,3)}
- \tlabel[cr](17.2,2.3){$\pi$}
- \tlabel[cr](17.2,-2.3){$-\pi$}
- \tlabel[cc](10,4){ log}
- \tlabel[cc](2,2.5){ $\Si$}
- \end{mfpic}%
- \closegraphsfile
- \end{document}