texworksでスペルチェッカーが機能しない

texworksでスペルチェッカーが機能しない

- H. K. の投稿
返信数: 7
Texlive2021.isoをWindows 10 proの新しいパソコンにインストールしました。
その後、スペルチェックの設定を行うため
webサイト:https://texwiki.texjp.org/?TeXworks%2F%E8%A8%AD%E5%AE%9A
の「スペルチェックの辞書の設定」の「Tex Live 2020の場合」に掲載されている方法と同様の以下の方法を実行しました。

1.https://addons.mozilla.org/ja/thunderbird/language-tools/ から辞書をダウンロードする.
2.ダウンロードしたファイルの拡張子を zip に変更して展開する.
3.TeXworks を起動してすぐに終了する.
4.C:\ユーザー\<ユーザー アカウント名>\.texlive2021\texmf-config\texworks\dictionaries フォルダーを作成して辞書(en-GB.aff と en-GB) を配置する.
5.TeXworks を起動して [編集] > [設定] > [エディタ] > [スペルチェッカの言語] から辞書を選択する.[編集] > [スペルチェック] で辞書を選択する.

しかし、Texworksの画面に辞書に登録されていない文字列をいくら入力しても、全くその部分に下線が表示されません。
パソコンを再起動させましたが、その後もうまくいきません。
以前、Tex Live 2019以前の版のインストールをした際にも同様の方法で行っていたと思います。

解決法を教えて頂きたいです。
よろしくお願いいたします。
H. K. への返信

Re: texworksでスペルチェッカーが機能しない

- 和田 勇 の投稿

ユーザ名が日本語かもしれないので再検証しましたが、特に問題なく動作することを確認しました。添付した画像も参考にしてください。

確認事項

  • TeXworks のスペルチェック用辞書設定の反映確認

    .\.texlive2021\texmf-config\texworks\scripts\Hooks\babelLanguage.js このファイルに設定が書き込まれる
    24:spellingDict.UKenglish = "en_GB";
    25:spellingDict.british   = "en_GB";
    
  • tree コマンドでスペルチェック用辞書他の確認

    tree .\.texlive2021\texmf-config\texworks\ /f
    フォルダー パスの一覧
    ボリューム シリアル番号は 000000E9 B833:AC5B です
    C:\USERS\和田勇\.TEXLIVE2021\TEXMF-CONFIG\TEXWORKS
    │  TwFileVersions.db
    ├─completion
    ... 省略 ...
    ├─configuration
    ... 省略 ...
    ├─dictionaries このディレクトリに置かれていることを確認
    │      en-GB.aff   
    │      en-GB.dic
    │      README_en_GB.txt
    ├─scripts
    ... 省略 ...
    │  ├─Hooks
    │  │      babelLanguage.js スペルチェックなどの設定が書き込まれるファイル
    │  │      logParser.js
    ... 省略 ...
    
添付 スクリーンショット_2021-06-29_132620.png
和田 勇 への返信

Re: texworksでスペルチェッカーが機能しない

- H. K. の投稿
再検証までして頂きありがとうございます。
babelLanguage.jsの中身は以下のようになっています。私がパソコンに詳しくなく、設定が書き込まれているのか分からなかったのですが、ご教示頂いた24,25行目は正しくなっています。
// TeXworksScript
// Title: Babel language
// Description: Looks for a Babel line to set the spell-check language
// Author: Jonathan Kew & Stefan Löffler
// Version: 0.3.1
// Date: 2012-03-20
// Script-Type: hook
// Hook: LoadFile

var spellcheckModlineRE = new RegExp("% *!TEX +spellcheck *=", "i");
var babelRE = new RegExp("^[^%]*\\\\usepackage\\[(?:.+,)*([^,]+)\\]\\{babel\\}");

var spellingDict = new Array();

// extend or customize this list as needed
spellingDict.czech = "cs_CZ";
spellingDict.german = "de_DE";
spellingDict.germanb = "de_DE";
spellingDict.ngerman = "de_DE";
spellingDict.greek = "el_GR";
spellingDict.english = "en_US";
spellingDict.USenglish = "en_US";
spellingDict.american = "en_US";
spellingDict.UKenglish = "en_GB";
spellingDict.british = "en_GB";
spellingDict.spanish = "es_ES";
spellingDict.french = "fr_FR";
spellingDict.francais = "fr_FR";
spellingDict.latin = "la_LA";
spellingDict.latvian = "lv_LV";
spellingDict.polish = "pl_PL";
spellingDict.brazilian = "pt_BR";
spellingDict.brazil = "pt_BR";
spellingDict.portuges = "pt_PT";
spellingDict.portuguese= "pt_PT";
spellingDict.russian = "ru_RU";
spellingDict.slovak = "sk_SK";
spellingDict.slovene = "sl_SL";
spellingDict.swedish = "sv_SV";

// get list of available dictionairies to avoid overriding the default spell
// checking language by "None" in case we tried to set the language to something
// for which no dict exists.
var dicts = TW.getDictionaryList();

function startsWith(haystack, needle)
{</font></div> <div><font size="2"> if (needle.length > haystack.length) {</font></div> <div><font size="2"> return false;</font></div> <div><font size="2"> }
return haystack.substr(0, needle.length) === needle;
}

function trySetSpellcheckLanguage(lang)
{</font></div> <div><font size="2"> // See if we have any entry for this in our list</font></div> <div><font size="2"> if (spellingDict[lang] === undefined) {</font></div> <div><font size="2"> return false;</font></div> <div><font size="2"> }
// map the babel code to an ISO language code
lang = spellingDict[lang];
// If we have a matching dict, set it
if (dicts[lang] !== undefined) {</font></div> <div><font size="2"> TW.target.setSpellcheckLanguage(lang);</font></div> <div><font size="2"> TW.result = "Set spell-check language to " + lang;</font></div> <div><font size="2"> return true;</font></div> <div><font size="2"> }
// Otherwise, see if we have a specialized dict (e.g., de_DE_frami when de_DE
// is requested).
for (var d in dicts) {</font></div> <div><font size="2"> if (startsWith(d, lang)) {</font></div> <div><font size="2"> TW.target.setSpellcheckLanguage(d);</font></div> <div><font size="2"> TW.result = "Set spell-check language to " + d;</font></div> <div><font size="2"> return true;</font></div> <div><font size="2"> }
}
return false;
}

// get the text from the document window
var txt = TW.target.text;
var lines = txt.split('\n');

// look for a babel line...
for (var i = 0; i < lines.length; ++i) {</font></div> <div><font size="2"> var line = lines[i];</font></div> <div><font size="2"> // If we have a "%!TeX spellcheck" modline, we don't override it (after all,</font></div> <div><font size="2"> // the user has probably put it there for a reason)</font></div> <div><font size="2"> if (spellcheckModlineRE.test(line)) {</font></div> <div><font size="2"> break;</font></div> <div><font size="2"> }
var matched = babelRE.exec(line);
if (matched) {</font></div> <div><font size="2"> if (trySetSpellcheckLanguage(matched[1])) {</font></div> <div><font size="2"> break;</font></div> <div><font size="2"> }
}
// ...but give up at the end of the preamble
if (line.match("\\\\begin\\{document\\}")) {</font></div> <div><font size="2"> break;</font></div> <div><font size="2"> }
if (line.match("\\\\starttext")) { // oops, seems to be ConTeXt!</font></div> <div><font size="2"> break;</font></div> <div><font size="2"> }
}
undefined;

tree コマンドでスペルチェック用辞書他の確認結果は次のようになりました:

tree .\.texlive2021\texmf-config\texworks\ /f
フォルダー パスの一覧
ボリューム シリアル番号は 000000F8 32A8:92CB です
C:\USERS\KIYOIKI_HOSHINO\.TEXLIVE2021\TEXMF-CONFIG\TEXWORKS
│ TwFileVersions.db
├─completion
│ tw-basic.txt
│ tw-beamer.txt
│ tw-context.txt
│ tw-latex.txt
├─configuration
│ auto-indent-patterns.txt
│ delimiter-pairs.txt
│ smart-quotes-modes.txt
│ syntax-patterns.txt
│ tag-patterns.txt
│ texworks-config.txt
│ tools.ini
├─dictionaries
│ en-GB.aff
│ en-GB.dic
│ README_en_GB.txt
├─scripts
│ │ launchPdf.js
│ │ makeBold.lua
│ │ makeBold.py
│ │ system.js
│ │
│ ├─Hooks
│ │ babelLanguage.js
│ │ logParser.js
│ │
│ ├─LaTeX styles
│ │ toggleBold.js
│ │ toggleEmph.js
│ │
│ └─Text transforms
│ titlecase.js
├─templates
│ ├─Basic LaTeX documents
│ │ article.tex
│ │ letter.tex
│ │
│ ├─Beamer presentations
│ │ conference-ornate-20min.en.tex
│ │ generic-ornate-15min-45min.en.tex
│ │ speaker_introduction-ornate-2min.en.tex
│ │
│ ├─More LaTeX classes
│ │ KOMA-letter.tex
│ │ memoir.tex
│ │
│ └─XeLaTeX documents
│ article-fontspec.tex
├─translations
│ qtbase_ca.qm
│ qtbase_cs.qm
│ qtbase_de.qm
│ qtbase_fr.qm
│ qtbase_it.qm
│ qtbase_ja.qm
│ qtbase_ko.qm
│ qtbase_pl.qm
│ qtbase_ru.qm
│ qtmultimedia_ca.qm
│ qtmultimedia_cs.qm
│ qtmultimedia_de.qm
│ qtmultimedia_fr.qm
│ qtmultimedia_it.qm
│ qtmultimedia_ja.qm
│ qtmultimedia_ko.qm
│ qtmultimedia_pl.qm
│ qtmultimedia_ru.qm
│ QtPDF_af.qm
│ QtPDF_ar.qm
│ QtPDF_ca.qm
│ QtPDF_cs.qm
│ QtPDF_de.qm
│ QtPDF_es.qm
│ QtPDF_fa.qm
│ QtPDF_fo.qm
│ QtPDF_fr.qm
│ QtPDF_it.qm
│ QtPDF_ja.qm
│ QtPDF_ko.qm
│ QtPDF_nl.qm
│ QtPDF_nn.qm
│ QtPDF_pl.qm
│ QtPDF_pt_BR.qm
│ QtPDF_ru.qm
│ QtPDF_sl.qm
│ QtPDF_tr.qm
│ QtPDF_zh_CN.qm
│ qtquick1_ca.qm
│ qtquick1_cs.qm
│ qtquick1_de.qm
│ qtquick1_fr.qm
│ qtquick1_it.qm
│ qtquick1_ja.qm
│ qtquick1_ko.qm
│ qtquick1_pl.qm
│ qtquick1_ru.qm
│ qtscript_ca.qm
│ qtscript_cs.qm
│ qtscript_de.qm
│ qtscript_fr.qm
│ qtscript_it.qm
│ qtscript_ja.qm
│ qtscript_ko.qm
│ qtscript_pl.qm
│ qtscript_ru.qm
│ qtxmlpatterns_ca.qm
│ qtxmlpatterns_cs.qm
│ qtxmlpatterns_de.qm
│ qtxmlpatterns_fr.qm
│ qtxmlpatterns_it.qm
│ qtxmlpatterns_ja.qm
│ qtxmlpatterns_ko.qm
│ qtxmlpatterns_pl.qm
│ qtxmlpatterns_ru.qm
│ qt_ar.qm
│ qt_ca.qm
│ qt_cs.qm
│ qt_de.qm
│ qt_es.qm
│ qt_fa.qm
│ qt_fr.qm
│ qt_it.qm
│ qt_ja.qm
│ qt_ko.qm
│ qt_nl.qm
│ qt_pl.qm
│ qt_pt_BR.qm
│ qt_ru.qm
│ qt_sl.qm
│ qt_tr.qm
│ qt_zh_CN.qm
│ TeXworks_af.qm
│ TeXworks_ar.qm
│ TeXworks_ca.qm
│ TeXworks_cs.qm
│ TeXworks_de.qm
│ TeXworks_es.qm
│ TeXworks_fa.qm
│ TeXworks_fo.qm
│ TeXworks_fr.qm
│ TeXworks_it.qm
│ TeXworks_ja.qm
│ TeXworks_ko.qm
│ TeXworks_nl.qm
│ TeXworks_nn.qm
│ TeXworks_pl.qm
│ TeXworks_pt_BR.qm
│ TeXworks_ru.qm
│ TeXworks_sl.qm
│ TeXworks_tr.qm
│ TeXworks_zh_CN.qm
└─TUG
TeXworks.ini

以下は、同様のテストを行った結果です。添付した画像です。やはり赤の下線が表示されません。
どのような問題が考えられますでしょうか。
教えて頂けると幸いです。よろしくお願いします。
添付 spellchecktest.png
H. K. への返信

Re: texworksでスペルチェッカーが機能しない

- 和田 勇 の投稿
  • 未だ解決には至っていないんですがいくつか再確認したいので

  • babelLanguage.js の spellingDict 関連は dictionary ディレクトリとの関係なので、標準で書かれているもののようでした。

  • ううむ ... 何が原因だろう
    • 違いですが私のところに無い・あるいは生成されていないものですが
      • templates そのものが無い
      • translations の下のたくさんのファイルは私のところには無い
  • babelLanguage.js は同じ内容だった
  • texworks は texlive2021 同梱のやつですよね

      wmic process where "name = 'texworks.exe'" get name,commandline
    
      結果は以下のような感じで表示されます
    
      CommandLine                               Name
      "C:\texlive\2021\bin\win32\texworks.exe"  texworks.exe
      texworks                                  texworks.exe
      
  • もう一つ画像確認
    • 「編集」→「スペルチェック」の状態は添付画像のように GB のメニューにチェックが入っているのですよね。
添付 スクリーンショット_2021-06-29_171038.png
和田 勇 への返信

Re: texworksでスペルチェッカーが機能しない

- H. K. の投稿
ご確認頂きありがとうございます。

● texworksはtexlive2021.isoを

https://ftp.jaist.ac.jp/pub/CTAN/systems/texlive/Images/

からインストールしたときに入ったものです。新しいパソコンなのでtexworksは他にないはずです。ですが、コマンドで
 wmic process where "name = 'texworks.exe'" get name,commandline
 を入力し実行すると「利用できるインスタンスがありません。」と表示されます。

        
「編集」→「スペルチェック」の所は末尾の画像のようにGBにチェックが入っています。

● コマンドとスペルチェックの結果は、templatesフォルダとtranslationsの中身を外しても変わりませんでした。

辞書の設定で初め、texlive2016で使用していた辞書ファイル(en-GB.aff と en-GB)をdictionariesフォルダに配置していて、うまくいかないので、辞書ファイルを削除し最初の投稿で記した手順の

1.https://addons.mozilla.org/ja/thunderbird/language-tools/ から辞書をダウンロードする.

からやり直したのですが、影響している可能性はありますでしょうか。

texlive2021を再インストールした方が良さそうでしょうか。

よろしくお願いいたします。
添付 spellchecktest2.png
H. K. への返信

Re: texworksでスペルチェッカーが機能しない

- H. K. の投稿
不思議なことに、パソコンのシステムの設定の「ディスプレイ」の「拡大縮小とレイアウト」の「テキスト、アプリ、その他の項目のサイズを変更する」の値を規定値の150%(推奨)から変更すると、texworksの赤線が適切に表示されるようになりました。

現状、取りあえずは問題なさそうなので、このままtexを使用しようと思います。

和田様、何度もご対応頂きありがとうございました。
H. K. への返信

Re: texworksでスペルチェッカーが機能しない

- 和田 勇 の投稿
  • 別解があったとのことなので検討を中断します

  • こちらでも再現しました

    • 2016 云々や 再インストールかということで私の手順を再度確認しようと思い texworks の再初期化を行うべく .texworks を削除したところ spell check エラー表示がされなくなってしまった :-(

    • regedit でリソースをと思いましたが面倒

    • .\AppData\Roaming\TUG\TeXworks の内容削除してみようかと思っていた矢先 ... 別解があったのこと ... 検討を中断
  • 補足「利用できるインスタンスがありません。」について

    • wmic process 云々のコマンドは
    • 現在実行しているプロセスを調べるもの → texworks が起動されいないと冒頭の警告が返されます
和田 勇 への返信

Re: texworksでスペルチェッカーが機能しない

- H. K. の投稿
大変お手間をとらせてしまい申し訳ありませんでした。エディタ画面の表示サイズが大きい事が気になってはいたのですが、なぜシステム設定の画面サイズを変えると解決したのか分かりません。

wmic processのコマンドについて、意味が分かっていませんでした。texworksを起動させた状態で実行すると、お示しの通りに表示されました。