Recent posts (max 5) - Browse or Archive for more

Highlighting a paragraph in LaTeX #2

In my  last post regarding this topic I couldn't really find a solution to highlight the background of a a paragraph in LaTeX when it contained block-level elements like citations.

What actually does work exactly as I wanted it to in the first place is using the  todonotes package:

\usepackage[bordercolor=white,backgroundcolor=gray!30,linecolor=black,colorinlistoftodos]{todonotes}
\newcommand{\rework}[1]{\todo[color=yellow,inline]{Rework: #1}}

Now marking up a paragraph in \rework{paragraph(s)} results in:

http://consense-project.com/raw-attachment/blog/latex_highlight_text_2/paragraph-highlight2.png

edit: this throws yet another an error

! TeX capacity exceeded, sorry [input stack size=1500].

when the paragraph contains a footnote. Oh well - will have to do for now anyway.

Procrastination 2.0

  • Posted: 2010-05-27 16:28 (Updated: 2010-05-27 16:44)
  • Author: hkbruegm
  • Categories: (none)
  • Comments (0)

Highlighting a paragraph in LaTeX

edit: see  Highlighting a paragraph in LaTeX #2 for a better solution to this.

When writing a text in Microsoft Word I like to highlight sections with a "neon marker" effect to have a clear visual guidance which parts still need some reviewing or for example need additional citations added. So basically this is how it should look in a LaTex generated PDF as well:


http://consense-project.com/raw-attachment/blog/latexhighlighttext/paragraph-highlight.png


Googling for  latex highlight paragraph blog posts like e.g.  devdaily.com suggest the following approach to highlight a paragraph:

Add the following to your preamble:

\usepackage{color}
\newcommand{\hilight}[1]{\colorbox{yellow}{#1}}

To highlight text in the body of your document, use

\hilight{this is some highlighted text}

There is a problem with the previous method is that the color box does not wrap properly. Here's a much easier and robust way of doing this

\usepackage{soul}

To highlight text in the body of your document, use

\hl{this is some highlighted text}

Unfortunately this approach works only if the highlighted paragraph contains no other nested block elements like a \citep tag. If you, like me, use such elements in the text you want to highlight you will get error messages which makes the Soul package quite unusable for the original purpose. Unfortunately I cant offer you a direct solution for this problem, but at least in my case highlighting the text itself (instead of marking up the background of the text) did its job.

For this use Preamble:

  \usepackage[usenames,dvipsnames]{color}
  \newcommand{\markup}[1]{{\color{Cerulean}{#1}}}

In the text: \markup{whatever text including \citep[p. 5f]{Brügmann.2010} lorem ipsum bla bla}

which results in:


http://consense-project.com/raw-attachment/blog/latexhighlighttext/paragraph_markup.png


If this causes an error of type option clash for package color you can comment out the /usepackage[][... line and simply include the dvipsnames switch in your global \documentclass options e.g.:

\documentclass[a4paper,oneside,dvipsnames]{book}

Finally for changing the color style in the /markup command see  WikiBooks:LaTeX/Colors.

Package natbib error: Bibliography not compatible with author year citation

LaTeX error message upon build:

Natbibbibliography not compatible with author year citation

In my case this was caused by a missing year entry in a bib-entry in  Mendeley. This caused something along these lines in bibliography.aux (important is the last line missing a year column):

\bibcite{Wurman.2000}{{27}{2000}{{Wurman}}{{}}}
\bibcite{Wurman2001}{{28}{2001}{{Wurman et~al.}}{{}}}
\bibcite{Xerox2008}{{29}{{Xerox Corporation}}{{}}}
  • add the missing year to whatever bib entry is missing that datum (either directly in the .bib file or indirectly in jabref or e.g. mendeley)
  • clear your bibliography.aux file
  • rebuild

Exporting Mediawiki Articles into Trac Wiki Pages

http://consense-project.com/raw-attachment/blog/mediawiki_export_to_trac-wiki/converter-icon.pngThe problem doesnt seem to be exactly new, but apparently not as common as one might think either: You want to migrate your  MediaWiki wiki pages into a (existing) Trac installation.

The following is the indirect path to the solution with explanations on how things work. for the direct solution go to section Direct Solution.

Indirect Solution

The  TracHelpPage says regarding this issue:

You can use the  attachment:wiki:TracWiki:mediawiki2trac.py Download script as a starting point. WikiProcessor for the MediaWiki styles has been started as trac plugin on  http://trac-hacks.org/wiki/MediaWikiPluginMacro.

You are supposed to download the mentioned mediawiki2trac.py from the above link, copy it into a directory on your (web)server and execute it with e.g.:

    python /PATH/mw2tw.py > mwexport-mediawiki2trac.sql

Unfortunately the script does only some minor importing without regard to versions, attachments (i.e. associated files) and redirects etc.

A bit more interesting is the following Trac ticket:  http://trac.edgewall.org/ticket/5241 especially regarding the different handling of attachment/media-files in MediaWiki and TracWiki. MediaWiki handles attached files in a completely different way than Trac does:

In Trac, you have attached files that are associated with a given page. Whereas in MediaWiki you have files that are uploaded and it's up to the wiki-editors to create links to the uploaded documents.
So, the process for dealing with "attachments" depends on a couple of factors.
If you want your downloaded documents to be unique in Trac like they are in mediawiki, then that's a problem. AFAIK, uniqueness in mediawiki is based on the filename whereas in Trac it's a combination of filename and what Wiki page the attachment is associated with.
So if you have an attachment that is linked in multiple places from on your MediaWiki page, then to have the same effect you'd either have to set up an independent web for these attachments (so all things would link to the same file) or you need to give up on the notion that the file is unique and that you have attachments that represent copies of the file in question.

So - whats wrong here:

  • First we don't want redirect pages to create stub-pages in Trac with no redirect functionality.
  • Secondly existing media-references should be kept intact.

As I am not really proficient with Python I reimplemented the migration script with PHP:

Features

  • Import directly from the MediaWiki MySql database into the Trac Sqlite3 database file
  • Convert basic MediaWiki markup to Trac markup (so no  separate MediaWiki parser for trac is needed)
  • Optionally remove category entries from wiki pages
  • Preserving Image/Media links. This assumes you manually copy the old mediawiki attachment files into a new flattened out directory (without the hashed subdirectories)
  • Optionally migrate revision comments
  • Optionally keep redirect-links intact. Even though Trac doesn't know redirects as MediaWiki does the script will change links to redirect pages so the link directly points to the real page
  • Optionally discard Stub pages
  • Optionally discard pages with fewer than X bytes
  • Remove custom specified substrings from pages (e.g. old MediaWiki templates)
  • Replace custom specified substrings with replacement-strings (e.g. custom copyright notices)

Limitations

There are some limitations though:

  • Complex markup (e.g. tables) will not be converted
  • As the script directly accesses the Trac Sqlite3 database file the corresponding Sqlite3 extension needs to be enabled in PHP
  • I personally didnt need this feature, so the script discards old revisions - if you take a look at the old python version of this script it shouldnt be hard to implement this though

Direct Solution

  1. Backup your trac database file - seriously - do it!
  2. Download and unzip the following script into a web-accessible directory on your webserver:  mediawiki2trac.zip
  3. Edit the settings section at the start of the script - comments should hopefully be self-explanatory.
  4. Call mediawiki2trac.php in a web browser.
    1. You need Sqlite3 support in PHP for the script to work. If you get an error message like Fatal error: Class 'SQLite3' not found in.... you are missing the extension. See for example  http://ubuntuforums.org/showthread.php?t=891767 on how to install this on Ubuntu.
    2. When calling the script it first starts in test-mode showing you what replacements etc would be done. Activate live processing by clicking on the given link.

  • Posted: 2010-04-14 02:53 (Updated: 2010-04-16 03:09)
  • Author: hkbruegm
  • Categories: trac
  • Comments (0)