rstudio / tinytex

A lightweight, cross-platform, portable, and easy-to-maintain LaTeX distribution based on TeX Live
https://yihui.org/tinytex/
Other
985 stars 116 forks source link

Issues with hyphenation #97

Closed jreduardo closed 5 years ago

jreduardo commented 5 years ago

When I run pdflatex (or its friends xelatex, lualatex) on a document with package babel, option other than english, I receive the message:

%--- document.tex           |  %--- message after run pdflatex document.tex
                            |
\documentclass{article}     |  Package babel Warning: No hyphenation patterns were preloaded for
                            |  (babel)                the language `Portuguese' into the format.
\usepackage[brazil]{babel}  |  (babel)                Please, configure your TeX system to add them and
\usepackage[T1]{fontenc}    |  (babel)                rebuild the format. Now I will use the patterns
\usepackage[utf8]{inputenc} |  (babel)                preloaded for english instead on input line 55.
                            |
\begin{document}            |
                            |
Body text ...               |
                            |
\end{document}              |

Even after run fmtutils-sys --all (in terminal or using the wrapper tinytex::tlmgr_update()), the hyphenation don't work. The (final) output of fmtutils-sys --all is

Transcript written on dvilualatex.log.
fmtutil [INFO]: /home/eduardojr/.TinyTeX/texmf-var/web2c/luatex/dvilualatex.fmt installed.
fmtutil [INFO]: Disabled formats: 1
fmtutil [INFO]: Successfully rebuilt formats: 14
fmtutil [INFO]: Total formats: 15
fmtutil [INFO]: exiting with status 0

To try to debug this error, I installed a huge LaTeX distribution texlive and additional packages. And when I ran /usr/bin/pdflatex document.tex the output was fine and the hyphenation worked.

Faced with this, I tried to put the files related to the packages that make the hyphenation side by side. But I didn't find crucial differences, everything seems equal (config/language*, babel/portuges.sty, hyphen/hyphen.tex).

Do you have any idea what could be wrong?

>  devtools::session_info(pkgs = "tinytex")

# ─ Session info ───────────────────────────────────────────────────────────────
#  setting  value
#  version  R version 3.5.2 (2018-12-20)
#  os       Ubuntu 18.04.1 LTS
#  system   x86_64, linux-gnu
#  ui       X11
#  language (EN)
#  collate  en_US.UTF-8
#  ctype    en_US.UTF-8
#  tz       America/Sao_Paulo
#  date     2019-02-10
#
# ─ Packages ───────────────────────────────────────────────────────────────────
#  package * version date       lib source
#  tinytex   0.10.3  2019-02-06 [1] Github (yihui/tinytex@299eee2)
#  xfun      0.4     2018-10-23 [1] CRAN (R 3.5.1)
#
# [1] /usr/lib/R/site-library
# [2] /usr/local/lib/R/site-library
# [3] /usr/lib/R/library

>  tinytex::tl_pkgs()

# tlmgr info --list --only-installed --data name
#   [1] "amscls"                      "amsfonts"
#   [3] "amsmath"                     "avantgar"
#   [5] "babel"                       "babel-english"
#   [7] "babel-portuges"              "beamer"
#   [9] "biblatex"                    "bibtex"
#  [11] "bibtex"                      "bookman"
#  [13] "booktabs"                    "caption"
#  [15] "charter"                     "cm"
#  [17] "cm-super"                    "cmextra"
#  [19] "collection-basic"            "collection-fontsrecommended"
#  [21] "colorprofiles"               "courier"
#  [23] "dehyph"                      "dvipdfmx"
#  [25] "dvipdfmx"                    "dvips"
#  [27] "dvips"                       "ec"
#  [29] "enctex"                      "etex"
#  [31] "etex-pkg"                    "etoolbox"
#  [33] "euenc"                       "euro"
#  [35] "euro-ce"                     "eurosym"
#  [37] "fancyhdr"                    "fancyvrb"
#  [39] "float"                       "fontspec"
#  [41] "fpl"                         "framed"
#  [43] "geometry"                    "glyphlist"
#  [45] "graphics"                    "graphics-cfg"
#  [47] "graphics-def"                "gsftopk"
#  [49] "gsftopk"                     "helvetic"
#  [51] "hyperref"                    "hyph-utf8"
#  [53] "hyphen-base"                 "ifetex"
#  [55] "ifluatex"                    "iftex"
#  [57] "ifxetex"                     "inconsolata"
#  [59] "knuth-lib"                   "knuth-local"
#  [61] "kpathsea"                    "kpathsea"
#  [63] "l3kernel"                    "l3packages"
#  [65] "lastpage"                    "latex"
#  [67] "latex-bin"                   "latex-bin"
#  [69] "latex-fonts"                 "latexconfig"
#  [71] "latexmk"                     "latexmk"
#  [73] "lm"                          "lm-math"
#  [75] "logreq"                      "lua-alt-getopt"
#  [77] "lualibs"                     "luaotfload"
#  [79] "luaotfload"                  "luatex"
#  [81] "luatex"                      "makecell"
#  [83] "makeindex"                   "makeindex"
#  [85] "manfnt-font"                 "marvosym"
#  [87] "mathpazo"                    "mathspec"
#  [89] "mathtools"                   "memoir"
#  [91] "metafont"                    "metafont"
#  [93] "metalogo"                    "mflogo"
#  [95] "mflogo-font"                 "mfware"
#  [97] "mfware"                      "ms"
#  [99] "natbib"                      "ncntrsbk"
# [101] "oberdiek"                    "palatino"
# [103] "parskip"                     "pdftex"
# [105] "pdftex"                      "pgf"
# [107] "plain"                       "psnfss"
# [109] "pxfonts"                     "realscripts"
# [111] "rsfs"                        "scheme-infraonly"
# [113] "supertabular"                "symbol"
# [115] "tetex"                       "tetex"
# [117] "tex"                         "tex-gyre"
# [119] "tex-gyre-math"               "tex-ini-files"
# [121] "tex"                         "texlive-common"
# [123] "texlive-docindex"            "texlive-en"
# [125] "texlive-msg-translations"    "texlive-scripts"
# [127] "texlive-scripts"             "texlive"
# [129] "texlive"                     "textpos"
# [131] "times"                       "tipa"
# [133] "titlesec"                    "titling"
# [135] "tools"                       "translator"
# [137] "txfonts"                     "unicode-data"
# [139] "updmap-map"                  "upquote"
# [141] "url"                         "utopia"
# [143] "wasy"                        "wasy2-ps"
# [145] "wasysym"                     "xcolor"
# [147] "xdvi"                        "xdvi"
# [149] "xetex"                       "xetex"
# [151] "xetexconfig"                 "xkeyval"
# [153] "xltxtra"                     "xunicode"
# [155] "zapfchan"                    "zapfding"
yihui commented 5 years ago

Does tinytex::tlmgr_install("hyphen-portuguese") solve the problem?

jreduardo commented 5 years ago

Ooh thanks, this worked (I'm ashamed of not having found this simple solution before :smile:). By the way, thank you for the tinytex package, it's nice!

yihui commented 5 years ago

No worries. Thanks for the confirmation! I think I can at least make the life of R users easier by providing a more helpful message when the hyphenation package is missing.

jreduardo commented 5 years ago

It would be great.

hplieninger commented 5 years ago

I had the same issue with German and want to share my solution for those coming across this issue.

Package babel Warning: No hyphenation patterns were preloaded for
                       the language `German (new orthography)' into the format.

The solution was to run tinytex::tlmgr_install("collection-langgerman")

Thank you, Yihui, for an awesome package.

yihui commented 5 years ago

@hplieninger Thanks for sharing the solution!

jrennstich commented 4 years ago

Unfortunately, I still run into the same issue. I have successfully installed all required files via tinytex::tlmgr_install("collection-langgerman") and still get that error msg. I checked specifically for the hyphen file and got the message tlmgr install: package already present: hyphen-german, and I checked the installed packages and they were all there. Any further suggestions how to tackle this?

UPDATE: I have updated all packages, to no avail. I am still getting the same error.

jrennstich commented 4 years ago

I still continue to get the error message, despite having uninstalled collection-langgerman) and reinstalled it again, hoping I would get the same result as @hplieninger .

I do get two error messages though:

fmtutil [WARNING]: inifile pdflatex.ini for pdflatex/pdftex not found.
fmtutil [WARNING]: inifile latex.ini for latex/pdftex not found.

Could that be related to my issue?

yihui commented 4 years ago

@jreduardo Could you try tinytex::tlmgr_install(c('texlive-scripts', 'dehyph-exptl'))? Thanks!

jrennstich commented 4 years ago

@jreduardo Could you try tinytex::tlmgr_install(c('texlive-scripts', 'dehyph-exptl'))? Thanks!

Thanks @yihui for the suggestion. This time the command worked, both pkgs were installed. Alas, no change. I also deinstalled and reinstalled using tinytex::tlmgr_install("collection-langgerman"). I keep getting those warnings:

fmtutil [WARNING]: inifile latex.ini for latex/pdftex not found.
fmtutil [WARNING]: inifile pdflatex.ini for pdflatex/pdftex not found.
jrennstich commented 4 years ago

Now it works. After deleting the folder Users/jrennstich/.TinyTeX and reinstalling everything it works.

yihui commented 4 years ago

@jreduardo Thanks for reporting back! https://tex.stackexchange.com/q/529413/9128

fkohrt commented 4 years ago

@yihui Using tinytex 0.25.1 I still get the warning

Package babel Warning: No hyphenation patterns were preloaded for
(babel) the language `German (new orthography)' into the format.
(babel) Please, configure your TeX system to add them and
(babel) rebuild the format. Now I will use the patterns
(babel) preloaded for \language=0 instead on input line 47.

Installing tinytex::tlmgr_install(c('texlive-scripts', 'dehyph-exptl')) doesn't remedy it, only tinytex::tlmgr_install("collection-langgerman") does. Maybe this should be taken care of automatically by the package?

yihui commented 2 years ago

Package babel Warning: No hyphenation patterns were preloaded for (babel) the language `German (new orthography)' into the format.

@fkohrt I think you only need tinytex::tlmgr_install("hyphen-german"). This will be taken care of automatically in the next version of tinytex. For now, you can install the development version:

remotes::install_github('yihui/tinytex')
paullemmens commented 1 year ago

I had the same problem for Dutch (on macOS) and for me too tinytex::tlmgr_install("hyphen-dutch") didn't resolve the issue. However, using babel-dutch instead did work.

memeplex commented 8 months ago

I'm not sure if https://github.com/rstudio/tinytex/commit/0f2007426f730a6ed9d45369233c1349a69ddd29 should be autoinstalling hyphen-spanish, but recently I had issues (https://github.com/quarto-dev/quarto-cli/issues/8684) using the tinytex bundle that's shipped with quarto, which I solved by manually installing hyphen-spanish.

yihui commented 8 months ago

@memeplex If you have the LaTeX log file, you can run tinytex:::check_babel() on it and see if tinytex is able to detect the missing package. I'm not sure if Quarto has included the patch I made in tinytex (https://github.com/rstudio/tinytex/commit/0f2007426f730a6ed9d45369233c1349a69ddd29).

memeplex commented 8 months ago

I'm not sure if Quarto has included the patch I made in tinytex (0f20074).

I suspect this may be the case, I've already suggested this possibility in their tracker. Thanks!

memeplex commented 8 months ago

Apparently they did: https://github.com/quarto-dev/quarto-cli/blob/078cac0de0a42bca9cfa788b17f160128193286c/src/command/render/latexmk/pdf.ts#L181C38-L181C65

This is the example that wasn't being hyphenated:

---
lang: es
---

automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente automáticamente

They answered:

We do support parsing of Babel warnings, but none are emitted in the example that you provided, so there isn't really a reasonable way for us to automatically detect this if the LaTeX engine isn't notifying us of any issue.

Do you think your solution will work in this example?

memeplex commented 8 months ago

Comparing the logs with and without hyphen-spanish installed I found this important difference:

> Package babel Info: Hyphen rules for 'spanish' set to \l@nil
> (babel)             (\language7). Reported on input line 128.

By inspecting the code, it doesn't seem to be detected, maybe they changed the way it is reported?

yihui commented 8 months ago

Maybe. I'll take a look and see if I can adapt tinytex:::check_babel() to the new form of babel messages.

yihui commented 8 months ago

I feel it will be nicer if babel could issue a warning instead of info in this case... That way, it will be easier for us to recognize the problem. We can definitely check info, too, but I'm not sure that's too much.

cderv commented 7 months ago

@yihui this is the new detection rule in Quarto : https://github.com/quarto-dev/quarto-cli/blob/6f4e15c09da45e675354498665d561e58cd4c425/src/command/render/latexmk/parse-error.ts#L110-L145

We now parse

// Try an alternative way of parsing
  const hyphenRulesRegex =
    /Package babel Info: Hyphen rules for '(.*?)' set to \\l@nil/m;

to install missing package

We can definitely check info, too, but I'm not sure that's too much.

I think it could be worth it.