Skip to content →

Latexrender and dvonn boards

In order
to blog a bit about Dvonn-strategy, I made myself a simple Dvonn
LaTeX-template which works very well on paper but which gets mutilated
by Latexrender, for example the first situation of the looks
like

$~\xymatrix@=.3cm @!C @R=.7cm{ & & \Black{2} \connS & &
\bull{d}{5} \conn & & \bull{e}{5} \conn & & \bull{f}{5} \conn & &
\bull{g}{5} \conn & & \bull{h}{5} \conn & & \SWhite \connS & & \SWhite
\connS & & \SWhite \conneS & & \\ & \bull{b}{4} \conn & & \SBlack
\connS & & \Black{6} \connS & & \bull{e}{4} \conn& & \bull{f}{4} \conn &
& \bull{g}{4} \conn & & \bull{h}{4} \conn & & \SWhite \connS & &
\SWhite \connS & & \SWhite \conneS & \\ \SBlack \connbeginS & &
\SBlack \connS & & \BDvonn{7} \connS & & \bull{d}{3} \conn & & \SBlack
\connS & & \BDvonn{6} \connS & & \bull{g}{3} \conn & & \bull{h}{3}
\conn & & \Dvonn \connS & & \SWhite \connS & & \SWhite \connendS \\ &
\Black{5} \connbeginS & & \bull{b}{2} \conn & & \SBlack \connS & &
\bull{d}{2} \conn & & \bull{e}{2} \conn & & \bull{f}{2} \conn & &
\bull{g}{2} \conn & & \bull{h}{2} \conn & & \SWhite \connS & & \SWhite
\connendS & \\ & & \bull{a}{1} \con & & \bull{b}{1} \con & & \Black{5}
\conS & & \bull{d}{1} \con & & \bull{e}{1} \con & & \bull{f}{1} \con & &
\bull{g}{1} \con & & \bull{h}{1} \con & & \White{2} & &} $

The
reason behind this unwanted clipping is that Latexrender uses
**convert** to take the relevant part of a ps-page containing only the
TeXed formula on an empty page by performing clipping and then converts
it into a GIF-file (or any other format you desire). The obvious way
round this is to enlarge my template by adding two additional rows and
columns and putting visible nonsense there (such as dots) to enlarge the
relevant part so that no clipping is done of essential info. But then
(1) the picture generated becomes even larger than that above and (2) I
don’t want you to see the extra nonsensical dots… The essential line
in the **class.latexrender.php** file is

$command =
$this->_convert_path." -density ".$this->_formula_density.
" -trim -transparent \"#FFFFFF\" ".$this->_tmp_filename.".ps ".
$this->_tmp_filename.".".$this->_image_format;

So
I needed to delve into the [manual pages for the convert command](http://amath.colorado.edu/computing/software/man/convert.html)
of the ImageMagick-package. To my surprise, the *-trim* option (which I
thought to adjust somewhat by adding parameters) doesn’t exist! Still, I
got around my second problem using the *crop* option and around the
first by using the very useful *geometry* option. The latter is also
useful if you find that the size of the output of Latexrender is not
compatible with the size of your regular text. Of course you can amend
this somewhat by using the *extarticle* documentclass (as suggested) but
if you want to further adjust it, use for example

-geometry
86%

to size the output to exactly 86% (or whatever you need).
So, whenever I want to do some Dvonn-blogging from now on I’ll change my
class.latexrender.php file as follows

$command =
$this->_convert_path." -crop 0x0-10% -crop 0x0+10% -density
".$this->_formula_density. " -geometry 80%
-transparent \"#FFFFFF\" ".$this->_tmp_filename.".ps ".
$this->_tmp_filename.".".$this->_image_format;

which
produces the output

$\xymatrix@=.3cm @R=.7cm{.& & & & & & & & & &
& & & \\ & & & \Black{2} \connS & & \bull{d}{5} \conn & & \bull{e}{5}
\conn & & \bull{f}{5} \conn & & \bull{g}{5} \conn & & \bull{h}{5} \conn
& & \SWhite \connS & & \SWhite \connS & & \SWhite \conneS & & & \\ & &
\bull{b}{4} \conn & & \SBlack \connS & & \Black{6} \connS & &
\bull{e}{4} \conn& & \bull{f}{4} \conn & & \bull{g}{4} \conn & &
\bull{h}{4} \conn & & \SWhite \connS & & \SWhite \connS & & \SWhite
\conneS & & \\ & \SBlack \connbeginS & & \SBlack \connS & &
\BDvonn{7} \connS & & \bull{d}{3} \conn & & \SBlack \connS & &
\BDvonn{6} \connS & & \bull{g}{3} \conn & & \bull{h}{3} \conn & &
\Dvonn \connS & & \SWhite \connS & & \SWhite \connendS & . \\ & &
\Black{5} \connbeginS & & \bull{b}{2} \conn & & \SBlack \connS & &
\bull{d}{2} \conn & & \bull{e}{2} \conn & & \bull{f}{2} \conn & &
\bull{g}{2} \conn & & \bull{h}{2} \conn & & \SWhite \connS & & \SWhite
\connendS & & \\ & & & \bull{a}{1} \con & & \bull{b}{1} \con & &
\Black{5} \conS & & \bull{d}{1} \con & & \bull{e}{1} \con & &
\bull{f}{1} \con & & \bull{g}{1} \con & & \bull{h}{1} \con & & \White{2}
& & & \\ . & & & & & & & & & & & & & } $

which (I hope) you will
find slightly better…

Published in web

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.