emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Hyphen after LaTeX fragments
@ 2023-03-13 15:15 Yuchen Guo
  2023-03-20  1:54 ` iemacs
  0 siblings, 1 reply; 15+ messages in thread
From: Yuchen Guo @ 2023-03-13 15:15 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 524 bytes --]

Sometimes I encounter such texts:

   One of the useful features of a basis $B$ in an $n$-dimensional space

When entered as-is in Org mode and exported to LaTeX, the string
"$n$-dimensional" is exported as plain text, as

  One of the useful features of a basis \(B\) in an \$n\$-dimensional space

However, in cases such as "$n$;" and "$n$.", they are correctly exported
as "\(n\);" and "\(n\).".

Are there any option to treat hypen the same as semicolon or full stop
in LaTeX exports?

-- 
Yuchen Guo


[-- Attachment #1.2: yc_pubkey.gpg.asc --]
[-- Type: application/pgp-keys, Size: 892 bytes --]

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Hyphen after LaTeX fragments
@ 2023-03-13 19:44 Yuchen Guo
  0 siblings, 0 replies; 15+ messages in thread
From: Yuchen Guo @ 2023-03-13 19:44 UTC (permalink / raw)
  To: emacs-orgmode

Sometimes I encounter such texts:

   One of the useful features of a basis $B$ in an $n$-dimensional space

When entered as-is in Org mode and exported to LaTeX, the string
"$n$-dimensional" is exported as plain text, as

  One of the useful features of a basis \(B\) in an \$n\$-dimensional space

However, in cases such as "$n$;" and "$n$.", they are correctly exported
as "\(n\);" and "\(n\).".

Are there any option to treat hypen the same as semicolon or full stop
in LaTeX exports?

-- 
Yuchen Guo


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Hyphen after LaTeX fragments
@ 2023-03-14  7:02 Yuchen Guo
  2023-03-14  7:04 ` Dominik Schrempf
  2023-03-14 11:12 ` Max Nikulin
  0 siblings, 2 replies; 15+ messages in thread
From: Yuchen Guo @ 2023-03-14  7:02 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 505 bytes --]

Sometimes I encounter such texts:

   One of the useful features of a basis $B$ in an $n$-dimensional space

When entered as-is in Org mode and exported to LaTeX, the string
"$n$-dimensional" is exported as plain text, as

   One of the useful features of a basis \(B\) in an \$n\$-dimensional space

In cases such as "$n$;" and "$n$.", they are correctly exported as
"\(n\);" and "\(n\).".

So, are there any option that can be tweaked to export "$MATH$-text"
correctly?

-- 
Yuchen Guo

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Hyphen after LaTeX fragments
  2023-03-14  7:02 Yuchen Guo
@ 2023-03-14  7:04 ` Dominik Schrempf
  2023-03-14 11:12 ` Max Nikulin
  1 sibling, 0 replies; 15+ messages in thread
From: Dominik Schrempf @ 2023-03-14  7:04 UTC (permalink / raw)
  To: Yuchen Guo; +Cc: emacs-orgmode

Hi!

I think we had this discussion quite some times already. Org Mode
supports $...$ syntax wherever possible but not in all places and
encourages the use of \(...\). I switched from using $...$ to \(...\)
everywhere, and have not had any problems since.

Dominik

Yuchen Guo <yuchen@apvc.uk> writes:

> [[PGP Signed Part:Undecided]]
> Sometimes I encounter such texts:
>
>    One of the useful features of a basis $B$ in an $n$-dimensional space
>
> When entered as-is in Org mode and exported to LaTeX, the string
> "$n$-dimensional" is exported as plain text, as
>
>    One of the useful features of a basis \(B\) in an \$n\$-dimensional space
>
> In cases such as "$n$;" and "$n$.", they are correctly exported as
> "\(n\);" and "\(n\).".
>
> So, are there any option that can be tweaked to export "$MATH$-text"
> correctly?


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Hyphen after LaTeX fragments
  2023-03-14  7:02 Yuchen Guo
  2023-03-14  7:04 ` Dominik Schrempf
@ 2023-03-14 11:12 ` Max Nikulin
  1 sibling, 0 replies; 15+ messages in thread
From: Max Nikulin @ 2023-03-14 11:12 UTC (permalink / raw)
  To: Yuchen Guo, emacs-orgmode

On 14/03/2023 14:02, Yuchen Guo wrote:
> Sometimes I encounter such texts:
> 
>     One of the useful features of a basis $B$ in an $n$-dimensional space
> 
> When entered as-is in Org mode and exported to LaTeX, the string
> "$n$-dimensional" is exported as plain text, as
> 
>     One of the useful features of a basis \(B\) in an \$n\$-dimensional space

I assume "\(n\)-dimensional".

> In cases such as "$n$;" and "$n$.", they are correctly exported as
> "\(n\);" and "\(n\).".
> 
> So, are there any option that can be tweaked to export "$MATH$-text"
> correctly?

Consider "$M$" as deprecated. Balance of lightweight markup and 
heuristics to distinguish literal symbols and markup markers is quite 
subtle. Dash detection is broken for a long time despite the manual 
still says that it is supported:

Max Nikulin to emacs-orgmode. Re: [PATCH] Add support for $…$ latex 
fragments followed by a dash. Tue, 1 Feb 2022 21:26:50 +0700. 
https://list.orgmode.org/stbfvc$3rs$1@ciao.gmane.io

That thread contains examples what may be false positives, e.g.

Max Nikulin to emacs-orgmode. Re: [PATCH] Add support for $…$ latex 
fragments followed by a dash. Sun, 30 Jan 2022 22:28:38 +0700. 
https://list.orgmode.org/st6ar8$tjk$1@ciao.gmane.io

Another thread:

Timothy to emacs-orgmode… Re: Depreciating TeX-style LaTeX fragments 
(was: Org Syntax Specification) Sun, 16 Jan 2022 00:36:35 +0800. 
https://list.orgmode.org/87lezgly20.fsf@gmail.com



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Hyphen after LaTeX fragments
  2023-03-13 15:15 Hyphen after LaTeX fragments Yuchen Guo
@ 2023-03-20  1:54 ` iemacs
  2023-03-21 16:35   ` Rudolf Adamkovič
  0 siblings, 1 reply; 15+ messages in thread
From: iemacs @ 2023-03-20  1:54 UTC (permalink / raw)
  To: Yuchen Guo; +Cc: org-mode mailing list

[-- Attachment #1: Type: text/plain, Size: 645 bytes --]

Hi,

You can write \(n\)-dimensional space.

On Wed, Mar 15, 2023, 02:18 Yuchen Guo <yuchen@apvc.uk> wrote:

> Sometimes I encounter such texts:
>
>    One of the useful features of a basis $B$ in an $n$-dimensional space
>
> When entered as-is in Org mode and exported to LaTeX, the string
> "$n$-dimensional" is exported as plain text, as
>
>   One of the useful features of a basis \(B\) in an \$n\$-dimensional space
>
> However, in cases such as "$n$;" and "$n$.", they are correctly exported
> as "\(n\);" and "\(n\).".
>
> Are there any option to treat hypen the same as semicolon or full stop
> in LaTeX exports?
>
> --
> Yuchen Guo
>
>

[-- Attachment #2: Type: text/html, Size: 1084 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Hyphen after LaTeX fragments
  2023-03-20  1:54 ` iemacs
@ 2023-03-21 16:35   ` Rudolf Adamkovič
  2023-03-21 16:39     ` Dominik Schrempf
  2023-03-21 17:22     ` Yuchen Guo
  0 siblings, 2 replies; 15+ messages in thread
From: Rudolf Adamkovič @ 2023-03-21 16:35 UTC (permalink / raw)
  To: iemacs, Yuchen Guo; +Cc: org-mode mailing list

iemacs@gmail.com writes:

> You can write \(n\)-dimensional space.

ROFL.

My apologies for the laugh, but this question will keep coming over and
over and over until the end of times.  Clearly, there is a need for the
dash, and given the quality and syntactic stability of TeX, the problem
is not going anywhere ... ever.

Rudy
-- 
"'Contrariwise,' continued Tweedledee, 'if it was so, it might be; and
if it were so, it would be; but as it isn't, it ain't.  That's logic.'"
-- Lewis Carroll, Through the Looking Glass, 1871/1872

Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Hyphen after LaTeX fragments
  2023-03-21 16:35   ` Rudolf Adamkovič
@ 2023-03-21 16:39     ` Dominik Schrempf
  2023-03-22 12:25       ` Ihor Radchenko
  2023-03-21 17:22     ` Yuchen Guo
  1 sibling, 1 reply; 15+ messages in thread
From: Dominik Schrempf @ 2023-03-21 16:39 UTC (permalink / raw)
  To: emacs-orgmode


I like the $...$ syntax, but since it is not fully supported, I rather
use \(...\) consistently; I do not really care.

Maybe the best thing to do is drop support for $...$ completely?

I quote the Org mode manual section about $...$ syntax:

    Text within the usual LaTeX math delimiters. To avoid conflicts with
    currency specifications, single ‘$’ characters are only recognized
    as math delimiters if the enclosed text contains at most two line
    breaks, is directly attached to the ‘$’ characters with no
    whitespace in between, and if the closing ‘$’ is followed by
    whitespace, punctuation or a dash. For the other delimiters, there
    is no such restriction, so when in doubt, use ‘\(...\)’ as inline
    math delimiters.

I think this is HIGHLY confusing. I think we should write something
along the lines: "Do not use $...$. Only for reasons of backwards
compatibility, $...$ syntax is partly (!) supported."

Dominik

Rudolf Adamkovič <salutis@me.com> writes:

> iemacs@gmail.com writes:
>
>> You can write \(n\)-dimensional space.
>
> ROFL.
>
> My apologies for the laugh, but this question will keep coming over and
> over and over until the end of times.  Clearly, there is a need for the
> dash, and given the quality and syntactic stability of TeX, the problem
> is not going anywhere ... ever.
>
> Rudy


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Hyphen after LaTeX fragments
  2023-03-21 16:35   ` Rudolf Adamkovič
  2023-03-21 16:39     ` Dominik Schrempf
@ 2023-03-21 17:22     ` Yuchen Guo
  2023-03-22 12:36       ` Ihor Radchenko
  1 sibling, 1 reply; 15+ messages in thread
From: Yuchen Guo @ 2023-03-21 17:22 UTC (permalink / raw)
  To: Rudolf Adamkovič, iemacs; +Cc: org-mode mailing list

[-- Attachment #1: Type: text/plain, Size: 511 bytes --]

If it is deprecated in Org mode, maybe we can print a warning message in
echo area?

> but this question will keep coming over and
> over and over until the end of times.

Yet I tried searching Org manual, and also here the mailing list
archive, before posting my latest lame message here.  Maybe I did not
use the correct keyword, maybe something else.

> Clearly, there is a need for the dash, and given the quality and
> syntactic stability of TeX, the problem is not going anywhere
> ... ever.

Absolutely.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Hyphen after LaTeX fragments
  2023-03-21 16:39     ` Dominik Schrempf
@ 2023-03-22 12:25       ` Ihor Radchenko
  2023-03-22 12:35         ` Dominik Schrempf
  0 siblings, 1 reply; 15+ messages in thread
From: Ihor Radchenko @ 2023-03-22 12:25 UTC (permalink / raw)
  To: Dominik Schrempf; +Cc: emacs-orgmode

Dominik Schrempf <dominik.schrempf@gmail.com> writes:

> Maybe the best thing to do is drop support for $...$ completely?

We cannot do it. Otherwise, existing Org documents may be broken.

> I quote the Org mode manual section about $...$ syntax:
>
>     Text within the usual LaTeX math delimiters. To avoid conflicts with
>     currency specifications, single ‘$’ characters are only recognized
>     as math delimiters if the enclosed text contains at most two line
>     breaks, is directly attached to the ‘$’ characters with no
>     whitespace in between, and if the closing ‘$’ is followed by
>     whitespace, punctuation or a dash. For the other delimiters, there
>     is no such restriction, so when in doubt, use ‘\(...\)’ as inline
>     math delimiters.
>
> I think this is HIGHLY confusing. I think we should write something
> along the lines: "Do not use $...$. Only for reasons of backwards
> compatibility, $...$ syntax is partly (!) supported."

Feel free to provide a patch.


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Hyphen after LaTeX fragments
  2023-03-22 12:25       ` Ihor Radchenko
@ 2023-03-22 12:35         ` Dominik Schrempf
  2023-03-22 13:02           ` Ihor Radchenko
  0 siblings, 1 reply; 15+ messages in thread
From: Dominik Schrempf @ 2023-03-22 12:35 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode


Ihor Radchenko <yantar92@posteo.net> writes:

> Dominik Schrempf <dominik.schrempf@gmail.com> writes:
>
>> Maybe the best thing to do is drop support for $...$ completely?
>
> We cannot do it. Otherwise, existing Org documents may be broken.
>

Well, and as detailed later in my mail, I meant deprecating support for
$...$. But thanks for pointing this out!

>
>> I quote the Org mode manual section about $...$ syntax:
>>
>>     Text within the usual LaTeX math delimiters. To avoid conflicts with
>>     currency specifications, single ‘$’ characters are only recognized
>>     as math delimiters if the enclosed text contains at most two line
>>     breaks, is directly attached to the ‘$’ characters with no
>>     whitespace in between, and if the closing ‘$’ is followed by
>>     whitespace, punctuation or a dash. For the other delimiters, there
>>     is no such restriction, so when in doubt, use ‘\(...\)’ as inline
>>     math delimiters.
>>
>> I think this is HIGHLY confusing. I think we should write something
>> along the lines: "Do not use $...$. Only for reasons of backwards
>> compatibility, $...$ syntax is partly (!) supported."
>
> Feel free to provide a patch.

I think that a change in the documentation alone is insufficient. We
need to make sure that all current and future maintainers of org-latex
are aware of the decision to deprecate $...$ (if we make this decision).
How do we do that?


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Hyphen after LaTeX fragments
  2023-03-21 17:22     ` Yuchen Guo
@ 2023-03-22 12:36       ` Ihor Radchenko
  2023-04-17 14:01         ` Ihor Radchenko
  0 siblings, 1 reply; 15+ messages in thread
From: Ihor Radchenko @ 2023-03-22 12:36 UTC (permalink / raw)
  To: Yuchen Guo; +Cc: Rudolf Adamkovič, iemacs, org-mode mailing list

[-- Attachment #1: Type: text/plain, Size: 170 bytes --]

Yuchen Guo <yuchen@apvc.uk> writes:

> If it is deprecated in Org mode, maybe we can print a warning message in
> echo area?

Not in echo area, but we can add a linter.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-lint-Add-checker-for-.-LaTeX-fragments.patch --]
[-- Type: text/x-patch, Size: 1628 bytes --]

From 129e3aa03229fd2e5dd6ea9bf627e4d95a061744 Mon Sep 17 00:00:00 2001
Message-Id: <129e3aa03229fd2e5dd6ea9bf627e4d95a061744.1679488572.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Wed, 22 Mar 2023 13:35:22 +0100
Subject: [PATCH] org-lint: Add checker for $...$ LaTeX fragments

* lisp/org-lint.el (org-lint-LaTeX-$): New checker warning about
semi-obsolete $...$ LaTeX fragment syntax.

Link: https://orgmode.org/list/86ileukojk.fsf@lan
---
 lisp/org-lint.el | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lisp/org-lint.el b/lisp/org-lint.el
index 0e2967b6c..8d6d22be7 100644
--- a/lisp/org-lint.el
+++ b/lisp/org-lint.el
@@ -1227,6 +1227,14 @@ (defun org-lint-incomplete-citation (ast)
                                        (org-element-property :parent text))
                  "Possibly incomplete citation markup")))))
 
+(defun org-lint-LaTeX-$ (ast)
+  "Report semi-obsolete $...$ LaTeX fragments."
+  (org-element-map ast 'latex-fragment
+    (lambda (fragment)
+      (and (string-match-p "^[$][^$]" (org-element-property :value fragment))
+           (list (org-element-property :begin fragment)
+                 "Potentially confusing LaTeX fragment format.  Prefer using more reliable \\(...\\)")))))
+
 \f
 ;;; Checkers declaration
 
@@ -1450,6 +1458,11 @@ (org-lint-add-checker 'incomplete-citation
   #'org-lint-incomplete-citation
   :categories '(cite) :trust 'low)
 
+(org-lint-add-checker 'LaTeX-$
+  "Report potentially confusing $...$ LaTeX markup."
+  #'org-lint-LaTeX-$
+  :categories '(markup))
+
 (provide 'org-lint)
 
 ;; Local variables:
-- 
2.39.1


[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: Hyphen after LaTeX fragments
  2023-03-22 12:35         ` Dominik Schrempf
@ 2023-03-22 13:02           ` Ihor Radchenko
  0 siblings, 0 replies; 15+ messages in thread
From: Ihor Radchenko @ 2023-03-22 13:02 UTC (permalink / raw)
  To: Dominik Schrempf; +Cc: emacs-orgmode

Dominik Schrempf <dominik.schrempf@gmail.com> writes:

>>> I think this is HIGHLY confusing. I think we should write something
>>> along the lines: "Do not use $...$. Only for reasons of backwards
>>> compatibility, $...$ syntax is partly (!) supported."
>>
>> Feel free to provide a patch.
>
> I think that a change in the documentation alone is insufficient. We
> need to make sure that all current and future maintainers of org-latex
> are aware of the decision to deprecate $...$ (if we make this decision).
> How do we do that?

$...$ is a part of Org markup spec.
We can document the deprecation in
https://orgmode.org/worg/org-syntax.html#LaTeX_Fragments and 
possibly as a comment in source code (org-element.el).

This is still under discussion in https://list.orgmode.org/orgmode/87r195nt2g.fsf@localhost/

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Hyphen after LaTeX fragments
  2023-03-22 12:36       ` Ihor Radchenko
@ 2023-04-17 14:01         ` Ihor Radchenko
  2023-04-17 15:29           ` Dominik Schrempf
  0 siblings, 1 reply; 15+ messages in thread
From: Ihor Radchenko @ 2023-04-17 14:01 UTC (permalink / raw)
  To: Yuchen Guo; +Cc: Rudolf Adamkovič, iemacs, org-mode mailing list

Ihor Radchenko <yantar92@posteo.net> writes:

> Yuchen Guo <yuchen@apvc.uk> writes:
>
>> If it is deprecated in Org mode, maybe we can print a warning message in
>> echo area?
>
> Not in echo area, but we can add a linter.

Applied, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=cfe5e01e1

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Hyphen after LaTeX fragments
  2023-04-17 14:01         ` Ihor Radchenko
@ 2023-04-17 15:29           ` Dominik Schrempf
  0 siblings, 0 replies; 15+ messages in thread
From: Dominik Schrempf @ 2023-04-17 15:29 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Yuchen Guo, Rudolf Adamkovič, iemacs, emacs-orgmode

Great, thank you so much!

Ihor Radchenko <yantar92@posteo.net> writes:

> Ihor Radchenko <yantar92@posteo.net> writes:
>
>> Yuchen Guo <yuchen@apvc.uk> writes:
>>
>>> If it is deprecated in Org mode, maybe we can print a warning message in
>>> echo area?
>>
>> Not in echo area, but we can add a linter.
>
> Applied, onto main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=cfe5e01e1


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-04-17 15:33 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-13 15:15 Hyphen after LaTeX fragments Yuchen Guo
2023-03-20  1:54 ` iemacs
2023-03-21 16:35   ` Rudolf Adamkovič
2023-03-21 16:39     ` Dominik Schrempf
2023-03-22 12:25       ` Ihor Radchenko
2023-03-22 12:35         ` Dominik Schrempf
2023-03-22 13:02           ` Ihor Radchenko
2023-03-21 17:22     ` Yuchen Guo
2023-03-22 12:36       ` Ihor Radchenko
2023-04-17 14:01         ` Ihor Radchenko
2023-04-17 15:29           ` Dominik Schrempf
  -- strict thread matches above, loose matches on Subject: below --
2023-03-13 19:44 Yuchen Guo
2023-03-14  7:02 Yuchen Guo
2023-03-14  7:04 ` Dominik Schrempf
2023-03-14 11:12 ` Max Nikulin

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).