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

[WORKAROUND] LaTeX quotation mechanism is broken #15003

Closed
vitaminace33 opened this issue Aug 21, 2021 · 10 comments
Closed

[WORKAROUND] LaTeX quotation mechanism is broken #15003

vitaminace33 opened this issue Aug 21, 2021 · 10 comments
Labels
German LaTeX Reported upstream stale marked as a stale issue/pr (usually by a bot)

Comments

@vitaminace33
Copy link
Contributor

Description :octocat:

The LaTeX quotation mechanism has been broken recently (1 week or less, I would say). I don't know if Spacemacs is to blame or some other package. A pure, clean Emacs session with uptodate AUCTeX works as expected.

Reproduction guide 🪲

  1. Create the following test file, test.tex.
\documentclass{minimal}
%\usepackage[german]{babel}
\begin{document}

Write a quoted word above.%
Write a quoted word below.%

\end{document}
  1. In a clean Emacs installation, rm -r ~/.emacs*, install AUCTeX, M-x package-install RET auctex RET, and add the following to ~/.emacs.
(setq TeX-parse-self t) ; Enable parse on load.
(setq TeX-auto-save t)  ; Enable parse on save.
  1. Restart and visit test.tex. Press double quote " once to get a two backticks ``, and twice to get a literal double quote ". Write something and press double quote " again once, two single quotes '', or twice,literal double quote ", to close the quote.
\documentclass{minimal}
%\usepackage[german]{babel}
\begin{document}
``Once''
Write a quoted word above.%
Write a quoted word below.%
"Twice"
\end{document}
  1. Clear (undo) changes, uncomment babel's line, save the file, restart and repeat the experiment (with now German quotation).
\documentclass{minimal}
\usepackage[german]{babel}
\begin{document}
"Once"
Write a quoted word above.%
Write a quoted word below.%
"`Twice"'
\end{document}
  1. Repeat the experiments 3 and 4 with Spacemacs (with LaTeX's layer). English quotation will work as expected, with a slight change: Pressing " will insert directly both opening and closing quotation marks (with cursor in between), ``''. German quotation (an any other language style) breaks: Pressing " erases or swaps some characters of the previous line and wrong chars are inserted. Perhaps the package that changes the English behavior is now breaking the other styles.
\documentclass{minimal}
\usepackage[german]{babel}
\begin{document''  % Closing bracket deleted and two single quotes inserted.
`                  % A single backtick inserted.
Write a quoted word above.%
Write a quoted word below''.% The .% ignored and two single quotes inserted.
`                  % A single backtick inserted.
\end{document}

Observed behaviour: 👀 💔
If German (or other language) style is activated, \usepackage[german]{babel}, pressing " erases or swaps some characters of the previous line and wrong chars are inserted.

Expected behaviour: ❤️ 😄
If German (or other language) style is activated, \usepackage[german]{babel}, pressing " once should insert "`"', twice "".

System Info 💻

  • OS: gnu/linux
  • Emacs: 27.1
  • Spacemacs: 0.300.0
  • Spacemacs branch: develop (rev. d9c3dc6)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: emacs
  • Completion: helm
  • Layers:
(emacs-lisp helm latex multiple-cursors treemacs)
  • System configuration features: XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS LIBSYSTEMD JSON PDUMPER LCMS2 GMP
@vitaminace33 vitaminace33 changed the title LaTeX quotation mechanism is broken [WORKAROUND] LaTeX quotation mechanism is broken Aug 21, 2021
@vitaminace33
Copy link
Contributor Author

vitaminace33 commented Aug 21, 2021

WORKAROUND

When the 4th element of TeX-quote-language is nil and both quote marks, 2nd and 3rd elements, are (non escaped) single characters, then the quotation mechanism works although not as expected for Spacemacs.

Add this snippet in dotspacemacs/user-config

  (add-hook 'TeX-language-de-hook
    (lambda ()
      (add-to-list 'TeX-quote-language-alist '("german" "\"`" "\"'" nil))))

It will override the default German style. Now, if you press " once, it will insert "`' instead of "`"', as expected (the escaped double quote is missing for some reason).

Rather than using TeX primitives for the Latin quotation marks, use UTF-8 chars.

  (add-hook 'TeX-language-de-hook
    (lambda ()
      (add-to-list 'TeX-quote-language-alist '("german" "«" "»" nil))))

Now, if you press " once, it will insert « instead of «», as expected in Spacemacs, but you can still close it pressing " once after having written some text.

@lebensterben
Copy link
Contributor

You should directly changing TeX-quote-language-alist.
The first element "german" runs TeX-language-de-hook.

Your workaround is self-referencing.

@vitaminace33
Copy link
Contributor Author

No, it is not, the hook is triggered by the german option for babel's package. AUCTeX, after parsing, applies the appropriate style, namely, german.el, which sets TeX-quote-language to ("german" "\"`" "\"'" t) and then calls TeX-language-de-hook. My workaround uses the hook to set TeX-quote-language-alist to ( ("german" "«" "»" nil) ), since the car of its only element coincides with the car of TeX-quote-language, it overrides it.

"German" is not a good label for the issue since this can happen for any language.

@lebensterben
Copy link
Contributor

lebensterben commented Aug 23, 2021

The quotations you preferred is not the default for German.
You can use French.

https://www.overleaf.com/learn/latex/Typesetting_quotations#Reference_guide

@lebensterben
Copy link
Contributor

try to disable smartparens-mode first

@vitaminace33
Copy link
Contributor Author

Good suggestion, after successfully disabling smartparens by adding it to dotspacemacs-excluded-packages, the quotation mark mechanism works as expected, that is, as in regular Emacs. I did suspect that the package electrifying pairs was the culprit, but I don't know how to continue from here.

@vitaminace33
Copy link
Contributor Author

The quotations you preferred is not the default for German.
You can use French.

https://www.overleaf.com/learn/latex/Typesetting_quotations#Reference_guide

I am to rewrite most language styles because some are missing and others are simply wrong. Still, this doesn't solve smartparens breaking quotations.

@lebensterben
Copy link
Contributor

@vitaminace33 you don't have to exclude this package all together.
Just have dotspacemacs-smartparens-strict-mode and dotspacemacs-activate-smartparens-mode set to nil.

;; If non-nil and `dotspacemacs-activate-smartparens-mode' is also non-nil,
;; `smartparens-strict-mode' will be enabled in programming modes.
;; (default nil)
dotspacemacs-smartparens-strict-mode nil
;; If non-nil smartparens-mode will be enabled in programming modes.
;; (default t)
dotspacemacs-activate-smartparens-mode t

Another way is to add a hook to LaTeX-mode-hook that turn off smartparens mode.

@vitaminace33
Copy link
Contributor Author

Thx @lebensterben, I went fast and furious ;-)

I notified upstream.

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Aug 25, 2022
@lebensterben lebensterben removed the stale marked as a stale issue/pr (usually by a bot) label Aug 25, 2022
Repository owner deleted a comment from github-actions bot Aug 25, 2022
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
German LaTeX Reported upstream stale marked as a stale issue/pr (usually by a bot)
Projects
None yet
Development

No branches or pull requests

2 participants