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

Process Babel main option #391

Closed
fh-igd-mueller-roemer opened this issue Aug 20, 2021 · 3 comments
Closed

Process Babel main option #391

fh-igd-mueller-roemer opened this issue Aug 20, 2021 · 3 comments
Assignees
Labels
1-feature-request ✨ Issue type: Request for a desirable, nice-to-have feature 3-fixed Issue resolution: Issue has been fixed on the develop branch
Milestone

Comments

@fh-igd-mueller-roemer
Copy link

fh-igd-mueller-roemer commented Aug 20, 2021

Is your feature request related to a problem? Please describe.
While parsing Babel package options, LTeX ignores the main option and instead only uses the order of the language options to select the main document language. For example, a document with

\usepackage[USenglish, main=ngerman]{babel} % or equivalently \usepackage[main=ngerman, USenglish]{babel}

is checked as en-US, despite the main language for Babel being set to de-DE (ngerman).

Describe the solution you'd like
LTeX parses and recognizes the main option and uses it - instead of language order - to select the main language if present.

Describe alternatives you've considered

Option A:
The other option to specify a main language in Babel is to pass the main language last:

\usepackage{USenglish, ngerman}{babel}

This method is parsed correctly by LTeX, however, this way of specifying the main language is less preferable and less beginner friendly, as it requires implicit knowledge of the meaning of the order of options in Babel. Furthermore, the use of a tool like LTeX should ideally not require writing ones LaTeX code differently.

Option B:
Another option may be to prioritize the % LTeX: language= magic comment over the document language set by parsing Babel language options.

@fh-igd-mueller-roemer fh-igd-mueller-roemer added the 1-feature-request ✨ Issue type: Request for a desirable, nice-to-have feature label Aug 20, 2021
@fh-igd-mueller-roemer fh-igd-mueller-roemer changed the title Babel main option is ignored Process Babel main option Aug 20, 2021
@valentjn
Copy link
Owner

Implemented. Note that using main to set the main language explicitly is discouraged by the babel authors themselves, except if actually necessary. And of course you need a basic knowledge of how to use a package in order to use it. See babel manual, Sec. 1.2:

You can also set the main language explicitly, but it is discouraged except if there [sic] a real reason to do so:

\documentclass{article}
\usepackage[main=english,dutch]{babel}

Examples of cases where main is useful are the following.

NOTE Some classes load babel with a hardcoded language option. Sometimes, the main language can be overridden with something like that before \documentclass:

\PassOptionsToPackage{main=english}{babel}

WARNING Languages may be set as global and as package option at the same time, but in such a case you should set explicitly the main language with the package option main:

\documentclass[italian]{book}
\usepackage[ngerman,main=italian]{babel}

@valentjn valentjn added the 3-fixed Issue resolution: Issue has been fixed on the develop branch label Aug 21, 2021
@valentjn valentjn self-assigned this Aug 21, 2021
@valentjn valentjn added this to the 11.1.0 milestone Aug 21, 2021
valentjn added a commit to valentjn/ltex-ls that referenced this issue Aug 21, 2021
@fh-igd-mueller-roemer
Copy link
Author

fh-igd-mueller-roemer commented Aug 23, 2021

I personally don't agree with then discouragement, but in any case, the last example is actually what I have right now, so my actual workaround was closer to

\documentclass[ngerman]{book}
\usepackage[USenglish, ngerman, main=ngerman]{babel}

Thank you very much!

@valentjn
Copy link
Owner

Feature released in 12.0.0.

me-johnomar added a commit to me-johnomar/ltex-ls that referenced this issue Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1-feature-request ✨ Issue type: Request for a desirable, nice-to-have feature 3-fixed Issue resolution: Issue has been fixed on the develop branch
Projects
None yet
Development

No branches or pull requests

2 participants