6

To make it short. My problem is this:

content of .tex file

Priorit"at is a german noun and means priority.

compare: \"a or {\"a}

it results in

Priorität is a german noun and means priority.

My spell checker (notepad++ /w aspell plugin) then complains, because it doesn't know Priorit and at. It doens't seem to recognize the whole word.

I want to automate the spellchecking process, since I have a certain amount of .tex files containing umlauts.

mike
  • 333
  • 1
    An idea would be to concatenate all files, replace the tex umlauts with uft8 chars and perform the spellchecking thereon. – mike May 29 '13 at 10:33
  • echo \find . -name '*.tex' -exec cat {} +` | sed 's/"u/ü/g; s/"U/Ü/g; s/"a/ä/g; s/"A/Ä/g; s/"o/ö/g; s/"O/Ö/g; s/"s/ß/g' >> all` but I still have to write back the changes. – mike May 29 '13 at 11:28
  • Having replaced "u with ü, etc., you can keep those characters in your .tex file. See my answer below. – John Wickerson May 29 '13 at 12:07
  • This approach changes the prerequisites. I'm still hoping that there is a solution to the problem in its current form. – mike May 29 '13 at 13:29

3 Answers3

1

If you put

\usepackage[utf8]{inputenc}

in your preamble, you can have umlauts and so on directly in your .tex files. I haven't used \"a to make an umlaut for ages - I just write ä directly in my .tex file.


Note. Within BibTeX files, you should revert to \"a, for the reason explained here: How to write “ä” and other umlauts and accented letters in bibliography?

  • You can't with latin1 input enc. I had problems with uft8 on cygwin, and since I also edit the files under osx I'd preferably stick to latin1. – mike May 29 '13 at 12:47
  • There's also utf8x. I don't understand the difference, but that's the one I use on OS X. – John Wickerson May 29 '13 at 13:07
0

I'm not satisfied, but here's my tentative solution

cd sources/
echo `find . -name '*.tex' -exec cat {} +` | sed -e 's/"u/ü/g; s/"U/Ü/g; s/"a/ä/g; s/"A/Ä/g; s/"o/ö/g; s/"O/Ö/g; s/"s/ß/g' -e "s/\\\'{e}/é/g" >> all
aspell -t -c all

But as aspell corrects the files interactively, you have to transfer the changes to the original .tex files.

EDIT

You can use following command to get a list with all spelling errors

echo `find . -name '*.tex' -exec cat {} +` | sed -e 's/"u/ü/g; s/"U/Ü/g; s/"a/ä/g; s/"A/Ä/g; s/"o/ö/g; s/"O/Ö/g; s/"s/ß/g' -e "s/\\\'{e}/é/g" | cat | aspell -t list
mike
  • 333
0

The following LaTeXspellcheck.sh bash-script might be helpful as it automatically replaces the typical e.g. \"u or {\ss} umlauts so that aspell works as usual. After the spell check the revised file will be translated back to the \"u format and compared to the original file. Here all changes can be accepted individually with [space] or all together with [CTL-A]. [CTL-S] saves the changes.

Note that the call of "kompare" is just a check if all translations worked fine. If you are sure about it, the original file might simply be replaced, but that is on own risk.

#!/bin/bash
#usage: LaTeXspellcheck.sh de_DE LaTeXdatei.tex
#usage: LaTeXspellcheck.sh en_US LaTeXfile.tex

#create two tempfiles in the temp-folder and label them with the script's name skriptname=basename "$0" skriptnameOhneEndung=${skriptname%.*} tempfile="${XDG_RUNTIME_DIR}/${skriptnameOhneEndung}.temp" rm -f $tempfile touch $tempfile tempfilezwo="${XDG_RUNTIME_DIR}/${skriptnameOhneEndung}.temp2" rm -f $tempfilezwo touch $tempfilezwo

#translate umlauts from LaTeX to normal cat $2 | sed 's/\"a/ä/g' | sed 's/\"o/ö/g' | sed 's/\"u/ü/g' | sed 's/\"A/Ä/g' | sed 's/\"O/Ö/g' | sed 's/\"U/Ü/g' | sed 's/{\ss}/ß/g' | sed 's/\-//g' > $tempfile

#spell check and write the result back to the tempfile aspell -t -l $1 -c $tempfile

#translate umlauts from normal to LaTeX and save them in a second temp file cat $tempfile | sed 's/ä/\"a/g' | sed 's/ö/\"o/g' | sed 's/ü/\"u/g' | sed 's/Ä/\"A/g' | sed 's/Ö/\"O/g' | sed 's/Ü/\"U/g' | sed 's/ß/{\ss}/g' > $tempfilezwo

#compare the result with the original file #just for checking if all translations are fine #accept changes individually with space or all together with CTL-A. #finally save changes with CTL-S kompare $tempfilezwo $2