User:Jonathan R. Williford/Converting LaTeX to Scholarpedia

From Scholarpedia
Jump to: navigation, search


    Converting Images

    mogrify -density 200 -flatten -format png *.ps

    The following process does not work well and is not recommended


    Before running pandoc, I preprocessed the LaTeX file for pandoc, using gvim's regex. I'm sure it is much better to make these changes in a script or to pandoc, but I was wanting to make it work quickly.

        %s/\\cite{\([^}]\+\)}/(CITE \1)/g
        %s/\\bibitem{\([^}]*\)}/(BIB \1)/g
        %s/\\begin{figure}/(BEGIN FIG)/g
        %s/\\end{figure}/(END FIG)/g
        %s/\\label{\([^}]*\)}\(\_..*\)(END FIG)/\2(LABEL \1)(END FIG)/g

    Some additional steps needed for another file:

        %s/\\centerline{\([^}]\+\)}/\1/g       # discard \centerline, but keep contents

    There should be something used for the typical \include function for figures, like this (not tested):


    Make sure to save the file as UTF-8. In vim you can do this with ":set fenc=utf-8".

    Pandoc conversion

        pandoc -s scholar2.tex -w mediawiki -o

    Post-processing steps

        %s/\((CITE [^)]\+)\)/(\1)/g

    Run until pattern not found:

        %s/(CITE \(\w\+\)\(\d\d\)\([abc]\?\),\?/[[#\1\2\3|\1 \2]](CITE /g

    and then

        %s/(CITE )//g
        %s/\]\]\[\[#/]], [[#/g
        %s/(BIB \(\w\+\))/<span id="\1"\/>/g
        %s/ <span/\r<span/g

    Dealing with rather complicated figure markup:

        %s/(BEGIN FIG)\(.*\)\(File:.*\.png\)\(.*\)(END FIG)/(BEGIN FIG)\2|thumb|400px|right| \1\3(END FIG)/g
        %s/(BEGIN FIG)\(.*right| \)\(.*\)(LABEL \(.*\))\(.*\)(END FIG)/(BEGIN FIG)\1\3|\2\4(END FIG)/g
        %s/(BEGIN FIG)\(.*\)(END FIG)/[[\1]]/g

    This is for the figures that were actually processed by pandoc:

        %s/\[\[Image:\([^|]\+\)|image\]\] (CAPTION)\(.*\)/File:\1|thumb|400px|right|\2/g

    Fix non-inline equations:

    Personal tools

    Focal areas