Articles I've written for customers on IT issues.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
5.3 KiB

4 years ago
  1. HOW TO GET STARTED
  2. Have latex2wp.py,latex2wpstyle.py, macrosblog.tex and your tex file
  3. in the same directory. Use post-template.tex as a starting
  4. point, writing your text between the \begin{document}
  5. and \end{document}.
  6. HOW TO USE
  7. In the directory in which latex2wp.py and your
  8. tex file are both present, type
  9. python latex2wp.py yourlatexfile.tex
  10. this will produce a file called yourlatexfile.html which
  11. is ready to be cut and pasted into WordPress.
  12. --------------------
  13. WHAT WORKS
  14. See the file example.tex to see how to import figures, have
  15. text appear in different colors, have links to URLs, and
  16. enter the "more" command of WordPress.
  17. Anything between a "\iftex . . . \fi" is compiled in LaTeX
  18. but ignored in the conversion to WordPress; anything between
  19. "\ifblog . . . \fi" is converted to WordPress but ignored
  20. by LaTeX. Anything between a "\iffalse . . . \fi" is ignored
  21. by both.
  22. A few macros are predefined, such as \E for \mathop{\mathbb E},
  23. \P for \mathop{\mathbb P} and so on.
  24. Several theorem-like numbered environments are supported,
  25. such as "theorem", "lemma", "proposition", "remark", "corollary",
  26. "example" and "exercise. In addition, there is the "proof"
  27. environment.
  28. You can use the inline math environment $...$ and the
  29. displayed math environments $$...$$, \[ ... \],
  30. \begin{equation} ... \end{equation}, and
  31. \begin{eqnarray*} ... \end{eqnarray*}.
  32. The tabular environment works
  33. \label{}, \eqref{} and \ref{} work in the standard way.
  34. -------------------
  35. WHAT DOESN'T WORK
  36. WordPress has some limitations to the kind of latex equations
  37. it can display. As a consequence, align and eqnarray are
  38. not supported. You can, however, use eqnarray* and you can use
  39. array inside a math environment.
  40. There is no support for \medskip, \bigskip and other such
  41. formatting commands. The return command \\ is recognized.
  42. \section, \section*, \subsection and \subsection* are supported,
  43. but not \subsubsection and so on.
  44. There is no support for bibliographic references
  45. There is no support for footnotes.
  46. ------------------------
  47. HOW TO CUSTOMIZE
  48. The file latex2wpstyle.py can be easily modified to
  49. make the program create pure HTML, to add new macros,
  50. to add new theorem-like environments or change their
  51. numbering conventions, or to change the typesetting
  52. design of theorem-like environments and other details.
  53. - Creating pure HTML:
  54. If the variable HTML is set to True
  55. at the beginning of the program, then pure HTML code
  56. is generated, which can be previewed locally with a browser.
  57. - Adding new macros:
  58. The variable M in latex2wpstyle.py contains
  59. a list of pair of strings. For every pair, every occurrence
  60. of the first string is replaced by an occurrence of the second
  61. string. Add your own macros as needed. Note that a backslash \
  62. must be written twice as \\, and a quote sign " must be written
  63. as \", so that for example the accent command \" must be written
  64. as \\\". Any macro you define in M must of course also be defined
  65. in macrosblog.tex in order for the latex file to be compiled
  66. and previewed as pdf.
  67. - Numbering conventions of numbered theorem-like environments:
  68. As in the TeX compiler, the program keeps several counters,
  69. for sections, subsections, equations, and theorem-like environments.
  70. Often, one wants certain environments to share the same counter, so
  71. that for example Lemma 2 is followed by Theorem 3 even if Theorem 3
  72. is the first theorem to appear.
  73. The variable T declared at the beginning of the program is a table
  74. that specifies which counter is used for which environment. Change
  75. the assignment to follow different numbering conventions. Any
  76. number strictly less than numberofcounters can be used to denote
  77. a counter in T. Increase the value of numberofcounters if you want
  78. to use a bigger range of counters in T.
  79. - Creating new theorem-like environments:
  80. Just add the name of the new environment, for example "conjecture",
  81. to the list ThmEnvs of currently supported environments. Choose a
  82. counter number, for example 0, to use for it, and add the entry
  83. "conjecture" : 0
  84. to T. Now the program recognizes \begin{conjecture}...\end{conjecture}
  85. and will number conjectures using counter 0. Add a \newtheorem
  86. definition in macrosblog.tex in order to be able to compile a
  87. latex file that uses this new environment.
  88. - Formatting of Theorem-like environments:
  89. The string beginthm specifies what to do at the
  90. beginning of a theorem-like environment. In the string,
  91. _ThmType_ will be replaced by the type of theorem
  92. (e.g. Theorem, or Lemma, or Corollary, etc.) and
  93. _ThmNumb_ will be replaced by the theorem number.
  94. So the standard setting
  95. beginthm= "\n<blockquote><b>_ThmType_ _ThmNumb_</b> <em>"
  96. will start a blockquote environment, write in boldface
  97. something like "Theorem 3", and then start an emphasized
  98. environment.
  99. beginnamedthm specifies what to do at the beginning of
  100. a theorem-like environment declared by something like
  101. \begin{theorem}[Fundamental Theorem of Calculus] ....
  102. the string _ThmName_ holds the content of the text in
  103. square brackets in the original LaTeX
  104. endthm specifies what to do at the end of a theorem-like
  105. environment.
  106. - Formatting of the proof environment
  107. Set the beginproof and endproof variables
  108. - Formatting of sections and subsections
  109. Set the section, sectionstar, subsection, and subsectionstar
  110. variables