* [OT] intelligent commas in math (in LaTeX) @ 2011-09-26 20:06 Mojca Miklavec 2011-09-29 16:15 ` Aditya Mahajan 0 siblings, 1 reply; 6+ messages in thread From: Mojca Miklavec @ 2011-09-26 20:06 UTC (permalink / raw) To: mailing list for ConTeXt users http://tug.org/pracjourn/2011-1/beccari.html ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [OT] intelligent commas in math (in LaTeX) 2011-09-26 20:06 [OT] intelligent commas in math (in LaTeX) Mojca Miklavec @ 2011-09-29 16:15 ` Aditya Mahajan 2011-09-30 7:36 ` luigi scarso 0 siblings, 1 reply; 6+ messages in thread From: Aditya Mahajan @ 2011-09-29 16:15 UTC (permalink / raw) To: mailing list for ConTeXt users On Mon, 26 Sep 2011, Mojca Miklavec wrote: > http://tug.org/pracjourn/2011-1/beccari.html Short summary: This allows the comma in $1, 2, 3$ to be have as punctuation comma (similar to \setupmathematics[autopunct=no]) and $1,23$ to behave as decimal comma (similar to \setupmatematics[autopunct=yes]). Since it is targeting pdftex and xetex engines, it makes , an active char in mathmode and redefines it as a macro that uses look ahead to check if the next token is a digit. In principle a cleaner implementation is possible in luatex (without using active characters), but I am not completely sure about this. It will be better to handle this as part of \mnum macro. Aditya ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [OT] intelligent commas in math (in LaTeX) 2011-09-29 16:15 ` Aditya Mahajan @ 2011-09-30 7:36 ` luigi scarso 2011-09-30 9:04 ` Philipp A. 2011-10-01 2:12 ` Aditya Mahajan 0 siblings, 2 replies; 6+ messages in thread From: luigi scarso @ 2011-09-30 7:36 UTC (permalink / raw) To: mailing list for ConTeXt users On Thu, Sep 29, 2011 at 6:15 PM, Aditya Mahajan <adityam@umich.edu> wrote: > On Mon, 26 Sep 2011, Mojca Miklavec wrote: > >> http://tug.org/pracjourn/2011-1/beccari.html > > Short summary: This allows the comma in $1, 2, 3$ to be have as punctuation > comma (similar to \setupmathematics[autopunct=no]) and > $1,23$ to behave as decimal comma (similar to > \setupmatematics[autopunct=yes]). Since it is targeting pdftex and xetex > engines, it makes , an active char in mathmode and redefines it as a macro > that uses look ahead to check if the next token is a digit. > > In principle a cleaner implementation is possible in luatex (without using > active characters), but I am not completely sure about this. It will be > better to handle this as part of \mnum macro. > > Aditya Hm, can you explain this a bit ? -- luigi ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [OT] intelligent commas in math (in LaTeX) 2011-09-30 7:36 ` luigi scarso @ 2011-09-30 9:04 ` Philipp A. 2011-10-01 2:12 ` Aditya Mahajan 1 sibling, 0 replies; 6+ messages in thread From: Philipp A. @ 2011-09-30 9:04 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1.1: Type: text/plain, Size: 94 bytes --] that would be very useful for sets and german decimals: $x = 1,33$ vs. $x ∈ {1, 2, 3, 4}$ [-- Attachment #1.2: Type: text/html, Size: 97 bytes --] [-- Attachment #2: Type: text/plain, Size: 485 bytes --] ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [OT] intelligent commas in math (in LaTeX) 2011-09-30 7:36 ` luigi scarso 2011-09-30 9:04 ` Philipp A. @ 2011-10-01 2:12 ` Aditya Mahajan 2011-10-01 6:16 ` luigi scarso 1 sibling, 1 reply; 6+ messages in thread From: Aditya Mahajan @ 2011-10-01 2:12 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1: Type: TEXT/PLAIN, Size: 2005 bytes --] >> In principle a cleaner implementation is possible in luatex (without using >> active characters), but I am not completely sure about this. It will be >> better to handle this as part of \mnum macro. >> > Hm, can you explain this a bit ? Currently ConTeXt already checks if '.' is part of a complete number or not as part of the export macros. For example: \m{x + 1.25y = 3.5} exports as <m:math display="inline"><m:mrow><m:mi>𝑥</m:mi><m:mo>+</m:mo><m:mn>1.25</m:mn><m:mi>𝑦</m:mi><m:mo>=</m:mo><m:mn>3.5</m:mn></m:mrow></m:math> Notice that 1.25 is part of a single <m:mn> tag. In contrast, if you use comma as a math delimiter, then the export function does not recognize the number correctly. \m{x + 1,25y = 3.5} exports as <m:math display="inline"><m:mrow><m:mi>𝑥</m:mi><m:mo>+</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>25</m:mn><m:mi>𝑦</m:mi><m:mo>=</m:mo><m:mn>3</m:mn><m:mo>,</m:mo><m:mn>5</m:mn></m:mrow></m:math> However, we do have a \mn macro (math number) to tag numbers. So you can type \m{x + \mn{1,25}y = \mn{3,5}} which exports as <m:math display="inline"><m:mrow><m:mi>𝑥</m:mi><m:mo>+</m:mo><m:mn>1,25</m:mn><m:mi>𝑦</m:mi><m:mo>=</m:mo><m:mn>3,5</m:mn></m:mrow></m:math> So, if we want to recognize ',' as a decimal separator, two solutions are possible in MkIV. The first is to build upon the existing export code that recognizes '.' as a decimal separator (to figure out the contents of the <mn> tag) to also recognize ',' as a decimal separator; The drawback of such an approach is that if you are in the habit of not adding a space after a comma, for example writing "Let $\naturalnumbers$ denote the set $\{1,2,3,\dots\}$ of natural numbers..." then you will get wrong output. So, an alternative option is to ask the user to tag all numbers with \mn. Then, the \mn{...} macro can redefine the comma so that the spaces around it match its use as a decimal separator. Aditya [-- Attachment #2: Type: text/plain, Size: 485 bytes --] ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [OT] intelligent commas in math (in LaTeX) 2011-10-01 2:12 ` Aditya Mahajan @ 2011-10-01 6:16 ` luigi scarso 0 siblings, 0 replies; 6+ messages in thread From: luigi scarso @ 2011-10-01 6:16 UTC (permalink / raw) To: mailing list for ConTeXt users On Sat, Oct 1, 2011 at 4:12 AM, Aditya Mahajan <adityam@umich.edu> wrote: >>> In principle a cleaner implementation is possible in luatex (without >>> using >>> active characters), but I am not completely sure about this. It will be >>> better to handle this as part of \mnum macro. >>> >> Hm, can you explain this a bit ? > > Currently ConTeXt already checks if '.' is part of a complete number or not > as part of the export macros. For example: > > \m{x + 1.25y = 3.5} > > exports as > > <m:math > display="inline"><m:mrow><m:mi>𝑥</m:mi><m:mo>+</m:mo><m:mn>1.25</m:mn><m:mi>𝑦</m:mi><m:mo>=</m:mo><m:mn>3.5</m:mn></m:mrow></m:math> > > Notice that 1.25 is part of a single <m:mn> tag. > > In contrast, if you use comma as a math delimiter, then the export function > does not recognize the number correctly. > > \m{x + 1,25y = 3.5} > > exports as > > <m:math > display="inline"><m:mrow><m:mi>𝑥</m:mi><m:mo>+</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>25</m:mn><m:mi>𝑦</m:mi><m:mo>=</m:mo><m:mn>3</m:mn><m:mo>,</m:mo><m:mn>5</m:mn></m:mrow></m:math> > > However, we do have a \mn macro (math number) to tag numbers. So you can > type > > \m{x + \mn{1,25}y = \mn{3,5}} > > which exports as > > <m:math > display="inline"><m:mrow><m:mi>𝑥</m:mi><m:mo>+</m:mo><m:mn>1,25</m:mn><m:mi>𝑦</m:mi><m:mo>=</m:mo><m:mn>3,5</m:mn></m:mrow></m:math> > > > So, if we want to recognize ',' as a decimal separator, two solutions are > possible in MkIV. The first is to build upon the existing export code that > recognizes '.' as a decimal separator (to figure out the contents of the > <mn> tag) to also recognize ',' as a decimal separator; > > The drawback of such an approach is that if you are in the habit of not > adding a space after a comma, for example writing "Let $\naturalnumbers$ > denote the set $\{1,2,3,\dots\}$ of natural numbers..." then you will get > wrong output. > > So, an alternative option is to ask the user to tag all numbers with \mn. > Then, the \mn{...} macro can redefine the comma so that the spaces around it > match its use as a decimal separator. > > Aditya ok -- luigi ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-10-01 6:16 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-09-26 20:06 [OT] intelligent commas in math (in LaTeX) Mojca Miklavec 2011-09-29 16:15 ` Aditya Mahajan 2011-09-30 7:36 ` luigi scarso 2011-09-30 9:04 ` Philipp A. 2011-10-01 2:12 ` Aditya Mahajan 2011-10-01 6:16 ` luigi scarso
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 NNTP newsgroup(s).