Extension talk:Wiki2LaTeX/Development/w2lParser.php
Add topicTable support
[edit]I've transplanted the table parser from mediaWiki into doTableStuff() and externalTableHelper(), so the parser is now totally compatible with the wiki table markup supported by mediaWiki. (Except captions, that requires some extra LaTeX fiddeling, like putting the table inside a figure, or something.)
To coax LaTeX into making a nice table, some extra input is needed. Therefore, I added support for an extra attribute "latexfmt" to the table. The attribute as then passed on to LaTeX to tell how many rows there are, and which type of cells should be used for each row. An extra cell type Y is introduced for left-aligned text than can wrap. Example:
{| latexfmt="|Y|l|r|" |- |+ Caption (will be ignored) |- ! header 1Â !! header 2 || header 3 |- |----------------------------------------------- | row 1, cell 1 is very very very long ong najsdf nasdfn awefjna werjfan erjane rjfner jfane rjfnaejrfa asd fas dfa sdf asdf asdf asdf asdf asdfer|| row 1, cell 2 || row 1, cell 3 |- | row 2, cell 1 | row 2, cell 2 | row 2, cell 3 |}
HTML-style tables can be supported by replacing <table>, <tr>, <td> etc. in processHtmlEntities(), but the tables will normally look terrible because the latexfmt attribute is missing.
-Ole, Aug 22nd 2007.
- "The attribute as then passed on to LaTeX to tell how many rows there are...", don't you mean "columns"? Could you post the tex script generated for this example so I can double check that what I'm seeing is correct? I don't get any vertical lines, unfortunately I wouldn't quite call it a "nice" table! Hoogs 11:03, 24 September 2007 (UTC)
- The error was caused by a typo above at the latexfmt-attribute. Should work now as expected.--HG 11:40, 24 September 2007 (UTC)
- I had already fixed that. I guess my point is that out of the box, this example isn't a particularly attractive table, or is it just me? Here is the test wikitext:
- The error was caused by a typo above at the latexfmt-attribute. Should work now as expected.--HG 11:40, 24 September 2007 (UTC)
{| latexfmt="|Y|l|r|" |- |+ Caption (will be ignored) |- ! header 1Â !! header 2 || header 3 |- |----------------------------------------------- | row 1, cell 1 || row 1, cell 2 || row 1, cell 3 |- | row 2, cell 1 | row 2, cell 2 | row 2, cell 3 |}
and using these options on the "latex" page:
Documentclass: Article Leave NoInclude-blocks in main Article Process Templates and Parserfunctions Use "W2L Plain" template from this site
here is the latex script produced:
\newcolumntype{Y}{>{\raggedright\arraybackslash}X}\begin{tabularx}{\linewidth}{|Y|l|r|}\hline \textbf{ header 1 } & \textbf{ header 2 } & \textbf{ header 3}\\ \hline row 1, cell 1 & row 1, cell 2 & row 1, cell 3\\ \hline row 2, cell 1 & row 2, cell 2 & row 2, cell 3\\ \hline \end{tabularx}
and the pdf produced. I have no problems if this functionality needs a bit more work, I'm just wondering if we really believe that this is "nice", or if the translation could be a bit better. Hoogs 06:02, 25 September 2007 (UTC)
- Well, I guess the template is outdated. You have to include the tabularx-package into the template-file, or you can use this one. The generated table should basically look like the Mediawiki-result, but with borders. I hope this helps.--HG 07:30, 25 September 2007 (UTC)
- Ah, ok thanks. I hadn't heard of that package before so thats why I wasn't sure what was going on in the latex file. This fresh template made all the difference, tables now look "nice". The more I use this the more I like it, has a lot of potential, I'll contribute where I can! Hoogs 10:55, 25 September 2007 (UTC)
?
[edit]Hi. I am a Wikimedia Brasil volunteer and I cordinate a training system we've implemented in a big brasilian company usin mediawiki 1.11. As I was surfing in Special pages/Version I´ve seen that numberofusers extension was installed by tecnololy crew (I am from human resources division). What is it for? It shows the number of users is logged? Thanks a lot for your attention, sorry for any writing mistake.