Étiquette : svg

  • [Debian] Generate TeX formulas as SVG or PNG images Wikipédia-like

    Preparation

    We will use this file named texfile.tex as the .tex to convert:

    Result file

    PNG demonstration
    PNG demonstration

    Generating PNG images

    Packages you need:

    • texlive (or any other TeX program, I guess)
    • dvipng

    Step by step

    1. In the Terminal, go to the directory containing the .tex file.
    2. Execute this:
      • Output:
    3. Convert to PNG at 150dpi (to get a larger image than default):
      • Output:
    4. Remove the border white spaces of the page and add some borders using imagemagick:
    5. Your file is ready as texfile_trimmed.png.

    Script

    I have made a little script to automatize the conversion, with auto-remove of intermediary files:

    Usage
    1. Save the above script as tex2png, anywhere you want, usually near your .tex files for convenience.
    2. Make it executable: $ chmod +x tex2png.
    3. Syntax: tex2png filename [-keeptempfiles].
      • Example: $ tex2png texfile.tex.
      • Alternatively, you can omit the .tex extension: $ tex2png texfile but I would not recommend it.
      • If you want to keep the intermediary files (dvi, log, etc.), add the -keeptempfiles argument at the end: $ tex2png texfile.tex -keeptempfiles.
    4. The final image is named texfile_trimmed.png

    Generating SVG images

    Packages you need:

    • texlive

    Step by step

    1. In the Terminal, go to the directory containing the .tex file.
    2. Execute this:
      • Output:
    3. Convert to a SVG image with a 1.5 scale factor:
    4. Your file is ready as texfile.svg.

    Remarks

    There is no padding in the SVG method. I have not found yet a method to add a little padding around the figure.

    Also, the --no-fonts is necessary to prevent rendering issues about SVG fonts, especially with Firefox and the default SVG viewer of Debian. So the generated formula will not be selectable as a text, but at least, it will render correctly on every device with SVG support.

    Background

    I needed to include some nice looking formulas on my new game design wiki. I am using MediaWiki but the math add-on was not working on my server (web hosting service, not mine). So I decided to create myself the images offline and upload them as regular image files, so that I don’t need to think too much about trying to set the add-on without having all the privileges I could have on a personal server.

  • [Illustrator] Unwanted rasterized gradients in SVG Tiny 1.1+ export fix

    English version lower!

    Vous avez vu ce super titre en anglais ? Héhé, je me prépare pour le Canada, c’est dans très bientôt !

    Je suis tombé sur un bug d’Illustrator CS5 qui me prévient de la rastérisation des dégradés lors de l’export d’un objet, qui contient évidemment un dégradé, dans le format SVG Tiny 1.1+.

    Explications

    Ce bug intervient lorsqu’un objet avec un dégradé a été tourné avec l’outil de transformation. Pour corriger ce problème, il suffit de repasser tous les objets que vous avez tournés en mode couleur unie puis en dégradé. Et normalement, l’exporteur ne rasterise plus les dégradés !

    Here comes the english version!

    An english title calls for an english content, eh? 🙂

    I have had a bug with the SVG Tiny 1.1+ exporter which says the gradients will be rasterized on export. Tiny 1.1+ is supposed to support gradients, so why does it have happen?

    This is a bug which occurs when you rotate with the transformation tool an object which has a gradient fill. To circumvent this bug, you just have to switch the color fill to plain color and return to gradient fill on all your objects you have rotated. And normally, the exporter will not (hopefully) rasterize your gradients anymore!