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

Support \mathds, \hdots, \DeclareMathOperator, \hspace #126

Closed
giuseppec opened this issue Dec 2, 2018 · 4 comments
Closed

Support \mathds, \hdots, \DeclareMathOperator, \hspace #126

giuseppec opened this issue Dec 2, 2018 · 4 comments
Milestone

Comments

@giuseppec
Copy link

I am using the command pandoc -s test.tex -o test.docx to convert a TeX file called test.tex with the following content to Word:

\documentclass{article}
\usepackage{amsmath, dsfont}
\DeclareMathOperator*{\argmin}{arg\,min}
\begin{document}
$$\mathds{R}$$
$$1, \hdots, n$$
$$\argmin_{x}$$
$$a \hspace{10pt} b$$
\end{document}

However, each equation is not converted and I am getting a warning

[WARNING] Could not convert TeX math '\mathds{R}', rendering as TeX:
  \mathds{R}
         ^
  unexpected "{"
  expecting "%", "\\label", "\\nonumber" or whitespace
[WARNING] Could not convert TeX math '1, \hdots, n', rendering as TeX:
  1, \hdots, n
           ^
  unexpected ","
  expecting "%", "\\label", "\\nonumber" or whitespace
[WARNING] Could not convert TeX math '\argmin_{x}', rendering as TeX:
  \argmin_{x}
         ^
  unexpected "_"
  expecting "%", "\\label", "\\nonumber" or whitespace
[WARNING] Could not convert TeX math 'a \hspace{10pt} b', rendering as TeX:
  a \hspace{10pt} b
           ^
  unexpected "{"
  expecting "%", "\\label", "\\nonumber" or whitespace

Is there any solution to get this converted?
PS: I was not sure if I should post this issue to https://github.com/jgm/texmath ?

@jgm jgm transferred this issue from jgm/pandoc Dec 2, 2018
@jgm jgm changed the title TeX to Word gives "[WARNING] Could not convert TeX math" Support \mathds, \hdots, \argmin, \hspace Dec 2, 2018
@jgm
Copy link
Owner

jgm commented Dec 2, 2018

Are these standard LaTeX commands or defined in some package? If so, which?

@jgm
Copy link
Owner

jgm commented Dec 12, 2018

  • \mathds is from mathds package, for double-stroke fonts. Try adding \let\mathds\mathbb to your document and pandoc should handle this fine. I'm not sure whether it makes sense to add support for this to texmath: probably.

  • \hdots seems to be the same as \ldots; at least I can't tell the output apart. Try adding \let\hdots\ldots. We should support this in texmath.

  • \argmin - I couldn't find any prepackaged version of this. See https://tex.stackexchange.com/questions/5223/command-for-argmin-or-argmax for some ways to define it. If you include one of these \newcommand definitions, it should work in pandoc.

  • \hspace - there's no good way to represent vertical spacing in our equation model, but we could skip this I suppose.

@jgm jgm added this to the 0.12 milestone Dec 12, 2018
@giuseppec
Copy link
Author

giuseppec commented Dec 13, 2018

thanks for clarification. Some comments:

  • mathds support would be great, since it adds suport for double-stroke numerals and looks better. For example, \mathbb{1} does not work but \mathds{1} works, see https://tex.stackexchange.com/a/227808/26830
  • Yeah I personally replaced \hdots with \ldots or \dots to get rid of the warnings.
  • \argmin in the minimal example from my first post I used \DeclareMathOperator*{\argmin}{arg\,min} to define the \argmin command, which is also the correct way to do this (see https://tex.stackexchange.com/a/5255/26830). I know that one could also just use a \newcommand definition but the question is: wouldn't it make sense to add support for \DeclareMathOperator* definitions in pandoc? Maybe this is not high prio but would make sense if you don't want to force people to translate their (dozends) \DeclareMathOperator definitions to \newcommand definitions.
  • skipping \hspace should be fine. Or replacing (or handling) it with some other spacing commands such as \quad or \; before converting it.

@jgm
Copy link
Owner

jgm commented Dec 13, 2018

Right. We should support \DeclareMathOperator in pandoc's latex reader.
And actually \hspace should be no problem to support (I was thinking of \vspace).

@jgm jgm changed the title Support \mathds, \hdots, \argmin, \hspace Support \mathds, \hdots, \DeclareMathOperator, \hspace Dec 13, 2018
jgm added a commit that referenced this issue Dec 14, 2018
@jgm jgm closed this as completed in 8c843c5 Dec 15, 2018
jgm added a commit that referenced this issue Dec 17, 2018
We now allow operators like `arg\,min`, converting the space
into unicode.

See #126.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants