HandWiki:HelpLaTeXExample

From HandWiki

Example Wiki page for Latex conversion

It should be said that it is impossible an ideal conversion of Wikitext to LaTeX. These languages are completely different and are designed for different purposes. Wikitext may have hundreds of templates that cannot be converted. However, if you keep your wiki article simple, the LaTeX conversion can be very reasonable.

This particular article can be converted to LaTeX without problems. Use the top-right Actions menu and select LaTeX Export. You will see a pop-up dialog with with a LaTeX version of this wiki article. Save it to a file "article.tex". To compile this article as a PDF file, use this command:

pdflatex article.tex

To process this LaTeX file without errors, make sure you copy the file "Histogram.pdf", and the BibTex file "ppbook1.bib" from the uploaded BibTeX files. This "ppbook1.bib" should be inserted at the bottom of the "article.tex" file as:

\bibliography{ppbook1.bib}

The command pdflatex will produce "article.pdf" file. Similarly, you can use the command latex and dvips if your images are the form of the EPS files.

If you use the following rules described below, your chances for a good conversion to LaTeX will be quite high.

What you should avoid

Do not use templates in your wiki pages. They cannot be easily converted!

How to include code

If you use some code, use "source" tag. For example,

def function(ref):
    print("OK")

It will be converter to verbatim statement.

How to include comments

Use the standard Wiki styles for comments is exactly as for the HTML:

It will be converted to the standard LaTeX "percent" sign comments. The multi-line will be converted to a single line.

Using nowiki statements

If you use nowiki tag inside wiki, it will be converted to LaTeX verbatim statement. This is an example: This is my no wiki message with the brackets [[and]] and (()) and other staff.

Citations

When you want to cite a paper, always use the tag "refbib" that supports BibTeX citations. This tag uses citations from uploaded BiBTeX files to HandWiki as explained in BibTeX citations section. The WikiTex like this:

This example cites Ref.<refbib>Pruneau:2017:DAT:3264685</refbib> and another <refbib>Chekanov:2016ppq</refbib>.

creates this sentence:

This example cites Ref.<refbib>Pruneau:2017:DAT:3264685</refbib> and another <refbib>Chekanov:2016ppq</refbib>

inside your wiki article. Such sentences converted to the LaTeX file by replacing the refbib with the cite tag. You can use several BibTeX keys separated by the comma to cite several articles.

After the LaTeX export, do not forget to include the BiBTeX file which was earlier uploaded to HandWiki. You can find these citations in Citation manager, while BibTeX files is downloadable from this location.

Mathematical formulas

This is a section with [math]\displaystyle{ F_2 }[/math] equation and other math [math]\displaystyle{ F^2=\ln(x)\sqrt{s} }[/math]. You can also use the inline formulars like this [math]\displaystyle{ \sum_{i=0}^\infty 2^{-i} }[/math].

If you want to show a LaTeX equation in a separate line, use this example:

[math]\displaystyle{ \mathrm{geometric series:}\quad \sum_{i=0}^\infty 2^{-i}=2 }[/math]

you can also use "block statement" that also show an equation on a separate line:

[math]\displaystyle{ \mathrm{geometric series:}\quad \sum_{i=0}^\infty 2^{-i}=2 }[/math]

Note that you make use double dollar sign too. This is a special case when the equation will be shown in the middle of the text. It will be shown as a block, converting the dollar signs into the "equation" statements. All equations will be enumerated. This is an example using the two dollar sign:

$$ S^{2}_{K}=\sum_{i=0}^\infty 2^{-i} - 2\ln(\beta)*\frac{\alpha}{\chi^2} $$

A common method in Wikipedia articles is to include ":" before the math tag. It creates a block with equation. Here is an example:

:<math>\nu = -\frac{d\varepsilon_\mathrm{trans}}{d\varepsilon_\mathrm{axial}} = 
-\frac{d\varepsilon_\mathrm{y}}{d\varepsilon_\mathrm{x}}= 
-\frac{d\varepsilon_\mathrm{z}}{d\varepsilon_\mathrm{x}} </math>

where
:<math>\nu</math> is the resulting Poisson ratio,
:<math>\varepsilon_\mathrm{trans}</math> is transverse strain
:<math>\varepsilon_\mathrm{axial}</math> is axial strain

This block of the WikiTex creates the following equations:

[math]\displaystyle{ \nu = -\frac{d\varepsilon_\mathrm{trans}}{d\varepsilon_\mathrm{axial}} = -\frac{d\varepsilon_\mathrm{y}}{d\varepsilon_\mathrm{x}}= -\frac{d\varepsilon_\mathrm{z}}{d\varepsilon_\mathrm{x}} }[/math]

where

[math]\displaystyle{ \nu }[/math] is the resulting Poisson ratio,
[math]\displaystyle{ \varepsilon_\mathrm{trans} }[/math] is transverse strain
[math]\displaystyle{ \varepsilon_\mathrm{axial} }[/math] is axial strain

The LaTeX Export command should find this style and convert correctly into the LaTeX equations.

In LaTeX, it is a common practice to reference equations. If you convert mathematical equations that are enclosed between the "math" tag, the LaTeX conversion will create labels for equations automatically. However, if you use equations with proper references as explained in HandWiki equations, the LaTeX conversion will recognize such references. This is an example:

Note that <xr id="eqn:In1"/>  displays the equation number between parenthesis.
:<equation id="eqn:In1" shownumber>
<math>
\Gamma_{2} = \sum_{i=0}^\infty 2^{-i}
</math>
</equation>

which is viewed as:

Note that <xr id="eqn:In1"/> displays the equation number between parenthesis.

<equation id="eqn:In1" shownumber>

[math]\displaystyle{ \Gamma_{2} = \sum_{i=0}^\infty 2^{-i} }[/math] </equation>

All references should be recognized if you perform the LaTeX conversion.

Text decorations

For Computing platform, plain text is a loose term for data (e.g. file contents) that represent only characters of readable material but not its graphical representation nor other objects (floating-point numbers, images, etc.). Note that interwiki links will be converted to plain text in LaTeX.

You can use various decorations for you WikiText articles: italic text, bold text and even 'bold and italic' text in your wiki.


Showing tables

WikiCode tables can be also transformed to the LaTeX commands. But you should avoid using complex tables with complex structures and styles. This basic table should be well converted to the LaTeX:

Orange Apple Pitch
Bread Pie Pitch
Butter Ice cream Table


The LaTeX conversion also supports referencing the tables. Here is a simple example of the sentence with a reference to table:

This example shows <xr id="tab:T1"/>.

<figtable id="tab:T1">

Orange Apple Pitch
Bread Pie Pitch

My caption of this table </figtable> which should be converted to LaTeX without issues (including the reference). The Wikicode of the above example is:

This example shows <xr id="tab:T1"/>.
<figtable id="tab:T1">
{|
|Orange
|Apple
|Pitch
|-
|Bread
|Pie
|Pitch
|}
<caption>My caption of this table</caption>
</figtable>

Showing figures

Figures can be included into the wiki using the usual statement as:

[[File:Histogram.pdf]]

which produces this image:

Histogram.pdf

This wiki statement will be converted to the usual:

\begin{figure}
\begin{center}
\includegraphics[width=0.95\textwidth]{Histogram.pdf}
\caption{}
\label{fig:Histogram.pdf}
\end{center}
\end{figure}

statement in the LaTeX document.

The best images are the images created in EPS and PDF formats. In addition, you can include a figure caption inside this image. Use this wiki text:

[[File:Histogram.pdf|400px|My description of this figure]]]

It will be seen as:

My description of this figure]

After exporting to LaTeX, the figure caption should be inserted. Note that LaTeX export ignores the sizes of the images.

Using lists

This is the standard lists (itemized and enumerated). Conversion to LaTeX can only be done using one level of lists. Enclosed lists are not supported

  • my text for item
  • second item
  • 3rd item

Some other text and another text

  • my 2nd text for item
  • second 3gd item
  • 3rd item

Some other text enumerated

  1. My first item
  2. second item
  3. this is my last item

Here is the general rule: use as little MediaWiki tags as possible. Then the chances for a successful conversion will be higher.