3

I am using LyX fro writing a bi-lingual document, for wich I use the following custom package definition under "Settings -> Language":

\usepackage[english,ngerman]{babel}

As soon as I add the second language "english", resulting in "ngerman" being the default one and english for occasionally use, the \vref references are using "on page" rather than the German version "auf Seite".

Does anyone have an idea on how to fix that? I read that varioref needs the language to be set with the document class but I wasn't able to find a way to do that in LyX.

Thank you!

EDIT:

Here is an minimal example of the not working behaviour:

\lyxformat 474
\begin_document
\begin_header
\language ngerman
\language_package \usepackage[english,ngerman]{babel}
\end_header

\begin_body

\begin_layout Section
A
\end_layout

\begin_layout Standard
Bitte vergleichen mit Kapitel 
\begin_inset CommandInset ref
LatexCommand vref
reference "sec:B"
\end_inset
.
\end_layout

\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
clearpage
\end_layout
\end_inset
\end_layout

\begin_layout Section
\begin_inset CommandInset label
LatexCommand label
name "sec:B"
\end_inset
B
\end_layout

\end_body
\end_document

This renders to

Bitte vergleichen mit Kapitel 2 on the following page.

but when you change line 5 to

\language_package default

it renders correctly to

Bitte vergleichen mit Kapitel 2 auf der nächsten Seite.

  • 1
    Minimal example? Note that a .lyx file is just a text file so it is easy to copy/paste. Please read wiki.lyx.org/FAQ/MinimalExample – scottkosty Mar 21 '16 at 4:00
  • Thank you for pointing that out. Great idea! I just added a minimal example. – Kie Mar 21 '16 at 4:21
  • OK I gave a workaround. By the way, your .lyx file is strange and possibly corrupted. Did you by chance edit it directly with a text editor? Be very careful if you do that. – scottkosty Mar 21 '16 at 5:05
  • Yes I did, I removed everything unnecessary, and it still opens perfectly well in my LyX without all the other boilerplate settings. :) I thought that was meant by minimal example. – Kie Mar 21 '16 at 5:07
  • 1
    Ah makes sense. I appreciate the effort but it is best to do that inside of LyX. The best way is to create a new document and build it up, rather than stripping down a complicated document, but I understand your approach also. You do not get an error with 2.1.x, but if you open the file you posted here (unless you resave within LyX before reopening) in LyX 2.2.0, you will get errors because lyx2lyx will run and will be confused by your manual edits. You're playing with fire, which is fine---it is fun and useful to play with fire as long as you are aware of the consequences :) – scottkosty Mar 21 '16 at 5:17
4

It is because of your custom loading of babel. If you give a custom command then LyX does not know what needs to be done. In this case, it has no idea that babel has been loaded so does not know that it needs to set the language as ngerman (although you put this in the document settings as far as LyX is concerned it is irrelevant). Using a custom command is like using ERT. It is useful but once you go ERT you are on your own.

If you need to use the custom babel option, you can still get the behavior you want by adding "ngerman" (without quotes) in Document > Settings > Document Class > Custom (under Class options).

  • The reason, why I am using the custom babel setting is to have both languages, "english" and "ngerman" loaded. If there is a more LyX-ish way of getting two languages loaded, I am very open to do it this way and rather stay out of the ERM realm. – Kie Mar 21 '16 at 5:09
  • Adding "ngerman" to the document class options helps. Thank you. – Kie Mar 21 '16 at 5:14
  • 1
    I see now. The best way to do that is to use English. The way to use English in LyX (or any language) is to write English text, highlight it, then go to Edit > Text Style > Customized > Language and choose "English." After you do that, all languages you are using (if you are using more than one) will show up under Edit > Language. – scottkosty Mar 21 '16 at 5:18
  • 1
    The benefit to marking the language as which language it is is that LyX will know how to handle things. Similarly, spellcheck will work. – scottkosty Mar 21 '16 at 5:19
  • 1
    Great tip! Thank you, I'll keep that in mind for my further work. Thanks a lot for your time. – Kie Mar 21 '16 at 5:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.