6

I'm writing in TeXstudio, using Spanish and English. I first loaded the babel package, and then used \selectlanguage within the text. In Options / Configure TeXstudio, I have selected Spanish as default language. This causes all text in English to be underlined in red (the program 'thinks' all the words are misspelled because they're in a language it didn't expect). Changing the default language to English makes the red underlining appear in the Spanish text instead. Here's the code used:

\documentclass[]{article}

\usepackage[utf8]{inputenc}
\usepackage[spanish,english]{babel} 

\begin{document}

\section{Primera parte}
\selectlanguage{english}
This section is written in English. %This is all underlined in red

\section{Segunda parte}
\selectlanguage{spanish}
Esta sección está escrita en español. 

\end{document}

Am I missing something really obvious here? I did try the 'Import dictionary' option.

4
  • This isn't a babel issue but a TeXstudio one (hence why I've tweaked the tags). The TeXstudio interface doesn't pay attention to what you're doing with Babel. For what it's worth I don't know of another spellchecking solution for you either
    – Chris H
    Oct 14, 2016 at 15:23
  • 1
    I don't know whether TeXStudio is able to spell check in two languages simultaneously. In any case this is not connected to babel, but it only depends on the editor's features.
    – egreg
    Oct 14, 2016 at 15:24
  • 1
    As people said, since it is related to editor feature, the only solution I see is to merge the dic files.
    – Sigur
    Oct 14, 2016 at 16:36
  • 1
    I'd like to see how that goes @Sigur, sounds nice. Or you could also separate the text into different files and \input them after. Then you wouldn't be obliterated with red underlined words... Oct 14, 2016 at 17:33

2 Answers 2

6

from the TeXstudio Wiki:

Spellchecking with multiple languages

TeXstudio only supports one dictionary per file for spellchecking. This is a limitation for documents with multiple languages, because all except the selected language are marked as errors. As a workaround, one can create a hybrid multi-language dictionary with HunspellMerge and use this one for spellchecking.

An alternative, is to just switch between multiple dictionaries, using the dictionary switch button in the statusbar.

6

Sometimes, the multilingual parts are cleanly separated, e.g. in a thesis where front-sheet and abstract are required in the universities native language, while the text can be in English. Or, as given in the original question, they are separate sections.

In such cases, the simplest option might be to split the document into \include or \input files, in such a manner, that each file contains only a single language.

TeXStudio then supports a "magic comment", that declares the spellchecker for a given file and can be added by the program itself, by clicking the language button in the status bar, which offers "insert language as TeX comment".

1
  • For anyone wondering: The "magic comment" in question is % !TeX spellcheck = en_GB where en_GB can be replaced with the name of the spellchecker one wants to use.
    – Rincewind
    Sep 29, 2022 at 12:34

You must log in to answer this question.

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