27

I'm looking for a way to integrate something like After the Deadline or a similarly sophisticated spell checking tool into writing LaTeX documents. I don't mind it hitting the network each time. I already use flyspell-mode in AucTeX.

Edit

After the deadline is a webapp service which checks text for spell checking, grammar and style. In some ways it is similar to Microsfot Word spell-checking, more specifically green underline suggestions. After the deadline is used on wordpress.com and there are firefox/chromium/openoffice plugins for it. I was wondering if anyone managed to get this or any other similar spell checker to work with LaTeX documents to check grammar and style. I'm asking for something which will parse the whole sentences, and not just words.

5
  • 4
    possible duplicate of Spell checking LaTeX documents Jul 27, 2010 at 15:17
  • I too suggest merging this question into the other one on spell-checking (possibly broadening its scope). It's basically "how to spell-check using an external program/library". Jul 27, 2010 at 16:38
  • You can simply import your latex document into Word, and spell check it there. There's an issue: telling Word that macros don't need checking, which is in principle solveable (you can tell Word that certain parts of the Word document aren't in a human language), but in practice requires programming. Jul 28, 2010 at 9:45
  • And the fact that Word is not available on Linux.... I have tried achieving something like that with OpenOffice but it is a pain so sync the changes back =(
    – Dima
    Jul 28, 2010 at 11:10
  • @Dima: Didn't see your response at the time! Virtualisation makes Word an option on Linux. It's not too expensive: the download options for Windows 7 Home Premium and Office Home & Student are about $200 together; there are plenty of free software virtualisation options for Linux. Or rather, I should say it's not too expensive if you think you'll use it enough: I guess I'm fairly unusual here for needing Word a lot. May 4, 2011 at 6:46

7 Answers 7

16

You can use the detex tool to strip LaTeX commands. If you do detex file.tex, it will output to stdout. Then, you can use the diction tool to analyse your text, and suggest improvements. Putting it all together:

detex file.tex | diction -bs

This will strip the LaTeX, and pipe it into diction with suggestions and "beginner mistakes" enabled.

For Debian/Ubuntu:

sudo apt-get install diction texlive-extra-utils

This will install detex and diction, as well as several other useful tools.

Since you mentioned that you're using Emacs, there is also diction.el which provides diction integration with Emacs. You can do M-x diction-buffer, and it will take care of detexing/dehtmling and show the diction results in a separate buffer. You can even hit enter on the individual results to be taken to approximately where the phrase is.

(If you do use diction.el, my version of detex didn't have the -C flag. I'm not sure of what it was meant to do, but if you search for 'detex -C' in the file, you can add other command line options if you want. Also, I recommend replacing 'diction -L' with 'diction -bsL')

4
  • Just a heads up. The diction.el link is down.
    – Malabarba
    Feb 24, 2014 at 12:06
  • languagetool may be a better alternative to diction
    – xuhdev
    Apr 11, 2016 at 10:45
  • Is there a way to expand (all, some, particular) macros before they are removed? I very often use macros to re-use boilerplate text and/or specific terms. A typical example is the glossary package. For example my TeX code is The \gls{op} checks if lore ipsum where \gls{op} expands to "operator", i.e. the final output in the PDF is "The operate checks if lore ipsum". However, detex simply removes the macro and the spell/grammar checker complains because the noun of the sentence is missing. Any solution to that?
    – nagmat84
    Aug 29, 2019 at 16:24
  • diction-buffer is not installed how can I install diction.el?
    – alper
    Jan 17, 2022 at 15:27
9

(This is a repeat of my post on a different thread.)

I've just finished writing a new tool for checking spelling and grammar directly on LaTeX files, called TeXtidote:

https://sylvainhalle.github.io/textidote

The program can remove markup from the file and send it to the Language Tool library, which performs a verification of both spelling and grammar in a dozen languages. What is unique to TeXtidote is that it keeps track of the relative position of words between the original and the "clean" text. This means that it can translate the messages from Language Tool back to their proper location directly in your source file. By default, TeXtidote produces an HTML report that shows your original sources, with the errors found by Language Tool highlighted at the correct location:

enter image description here

The tool is free and easy to install (OS-independent, requires Java). I encourage you to give it a try and tell me what you think! (More information about download/install/use can be found on the Readme page of the GitHub repository; click on the "Download" button on the web site to get there.)

2
  • Looks great but download link on the website seems dead :/ It corresponds to what I look for here
    – JeT
    May 8, 2021 at 10:48
  • 1
    The download link has been fixed. The tool is still actively maintained on GitHub. May 9, 2021 at 11:58
4
aspell -t -c <filename>

where < filename > is the name of the tex file you would like to spell check will also do the job if aspell (http://aspell.net/) is installed on your system. Here -t filters the tex keywords and the symbols and -c asks aspell to spellcheck.

1

Of course, one solution is to to use software like detex or pandoc to convert LaTeX to plain text and then use any of the spell/grammar checkers I have listed here or LibreOffice/OpenOffice Write. But my favorite solution is to use TeXstudio LaTeX editor which has builtin spellchecking and install LanguageTool extension for a more advanced analysis. Instructions for installation on Windows OS can be seen here.

1

I've found the proselint tool quite useful, in combination with a spell checker such as aspell as proposed by others.

proselint calls itself a “A linter for prose” and is a command-line utility written in Python. This should allow you to use it on almost every operation system. It can also be integrated with Emacs (I assume you use emacs, since you're using AucTeX) via Flycheck, according to the project's GitHub page.

1

You can try my texsc wrapper of GNU aspell:

gem install texsc
texsc --ignore=citet,citep,verbatim book.tex section1.tex

You can also specify your own additional vocabulary:

texsc --pws=vocab.pws book.tex
0

I have found great success with using detex to strip my document to the basic text detex file.tex > output.txt and then copying and pasting the text into the Grammarly (free) extension for Chrome.

I like this method because the only new application I need is detex and I can use the same method on my Windows and Linux machines.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .