Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically install hyphenation patterns when using polyglossia #322

Closed
3 tasks done
svraka opened this issue Aug 12, 2021 · 7 comments
Closed
3 tasks done

Automatically install hyphenation patterns when using polyglossia #322

svraka opened this issue Aug 12, 2021 · 7 comments

Comments

@svraka
Copy link

svraka commented Aug 12, 2021

Commit ceb2001 added support for automatic installation of some babel language packages. The same issue arises with polyglossia, used with XeLaTeX, as polyglossia only throws warnings if hyphenation patterns are not available.

Here's a minimal reproducible document:

\documentclass{article}

\usepackage{polyglossia}
\setmainlanguage{hungarian}

\begin{document}

\dots

\end{document}

And here's the relevant part from the logs:

Package polyglossia Warning: No hyphenation patterns were loaded for `hungarian
'
(polyglossia)                I will use \language=\l@nohyphenation instead on i
nput line 10.

In this case the required package for hyphenation patterns is hyphen-hungarian, which can be deduced from the logs. I haven't tested all languages but my understanding is that it should work for most languages.

Although English seems to be a special case, if you want use British spelling.

Package polyglossia Warning: No hyphenation patterns were loaded for British En
glish
(polyglossia)                I will use the patterns for US English instead on 
input line 187.

This requires the hyphen-english package. However, according to its description:

Additional hyphenation patterns for American and British English in ASCII encoding. The American English patterns (usenglishmax) greatly extend the standard patterns from Knuth to find many additional hyphenation points. British English hyphenation is completely different from US English, so has its own set of patterns.

I would argue TinyTeX should even include this packages by default, as it would be useful for anyone writing in English. The size is 201k.


By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('tinytex'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('yihui/tinytex').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@yihui
Copy link
Member

yihui commented Aug 13, 2021

In this case the required package for hyphenation patterns is hyphen-hungarian, which can be deduced from the logs

That sounds simple enough to implement (should be similar to ceb2001). Do you want to try a pull request?

Although English seems to be a special case, if you want use British spelling.

It seems the implementation won't be very clean. I tend to let users manually install the package.

I would argue TinyTeX should even include this packages by default, as it would be useful for anyone writing in English. The size is 201k.

I'm not familiar with polyglossia or the hyphen-* packages, and I'm not sure if they should be included by default. The size doesn't look bad, though.

Thanks!

@svraka
Copy link
Author

svraka commented Aug 16, 2021

That sounds simple enough to implement (should be similar to ceb2001). Do you want to try a pull request?

Sure, I can give it a crack in ~2-3 weeks after I come back from holiday.

I'm not familiar with polyglossia or the hyphen-* packages, and I'm not sure if they should be included by default. The size doesn't look bad, though.

If I'm not mistaken, the hyphen-* packages are not only used by polyglossia but babel too. Maybe even if one doesn't load babel?

@svraka
Copy link
Author

svraka commented Sep 21, 2021

Just started digging into this, and immediately ran into a problem: LaTeX wraps logfiles. It came up in my original examples but there are even longer language names (not to mention what to do with English variants).

Package polyglossia Warning: No hyphenation patterns were loaded for `portugues
e'

Warnings for babel are similar, and the current regex looks for the same pattern but apparently line breaks cannot occur there?

Have you ever had to deal with linebreaks in logfiles? I haven't found any logic for that in the package. LaTeX can be set to wrap longer lines by setting the max_print_line value in texmf.cnf but that either requires changes in the TinyTeX installation, or to each call to the LaTeX engine (see this TeX.SE answer and comments).

@yihui
Copy link
Member

yihui commented Sep 22, 2021

We can configure max_print_line in TinyTeX to a large value, e.g.,

tlmgr conf texmf max_print_line 10000

We need to run that in these places (after the lines):

https://github.com/yihui/tinytex/blob/10dd9361a97e6c1d56e0b42c58f08c5dd9db45c4/R/install.R#L382-L383

https://github.com/yihui/tinytex/blob/10dd9361a97e6c1d56e0b42c58f08c5dd9db45c4/tools/install-base.sh#L48

https://github.com/yihui/tinytex/blob/10dd9361a97e6c1d56e0b42c58f08c5dd9db45c4/tools/install-windows.bat#L59

@svraka You can include these changes in your PR or send a separate PR. If you are not familiar with the codebase of tinytex, I can also let @cderv do it since it's simple enough. Thanks!


Just for the record, it's also possible not to configure max_print_line in texmf.cnf but do it through the argument -cnf-line in command line, e.g.,

pdflatex -cnf-line=max_print_line=10000 test.tex

Personally I prefer LaTeX not to hard-wrap the log because that makes the log slightly more trickier to parse. I tend to just change max_print_line permanently in the config file. If users do not like it, they can delete this config with:

tlmgr conf texmf --delete max_print_line

@yihui
Copy link
Member

yihui commented Oct 21, 2021

Since I haven't heard back, I just added the max_print_line config by myself in 8e6dc53.

@svraka
Copy link
Author

svraka commented Oct 22, 2021

Thanks! Unfortunately I didn't have any time to work on a PR I hope to pick it up soon.

@yihui yihui closed this as completed in 66ece33 Oct 22, 2021
@yihui
Copy link
Member

yihui commented Oct 22, 2021

That's okay. I just did the work by myself. You may test the current dev version if you are interested. Thanks!

clrpackages pushed a commit to clearlinux-pkgs/R-tinytex that referenced this issue Nov 9, 2021
…0.35

Christophe Dervieux (2):
      Update and simplify GHA workflow (#334)
      remove curl to see if action is fixed (#337)

Yihui Xie (10):
      start the next version
      close #332: automatically switch to the 'latest' version when the 'daily' version is not accessible in install_tinytex()
      run `tlmgr conf texmf max_print_line 10000` to avoid wrapping lines in LaTeX log: rstudio/tinytex#322 (comment)
      fix #322: automatically install hypen-* packages in case of polyglossia warnings
      improve the fix for #332: when installing the daily build of TinyTeX, also try https://github.com/yihui/tinytex-releases/releases/tag/daily if yihui.org is not accessible
      in the batch/shell scripts to install the pre-built version of TinyTeX, download the installers from https://github.com/yihui/tinytex-releases/releases/tag/daily instead of yihui.org because the latter seems to unstable (for unknown reasons)
      more master -> main
      retry curl/wget in case of download failures (further enhance the fix for #270)
      http -> https
      CRAN release v0.35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants