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

MATHML and sin(...) or cos(...) #109

Closed
danielezambelli opened this issue Mar 6, 2023 · 6 comments
Closed

MATHML and sin(...) or cos(...) #109

danielezambelli opened this issue Mar 6, 2023 · 6 comments

Comments

@danielezambelli
Copy link

danielezambelli commented Mar 6, 2023

Hi Michal,
I have found some errors when compiling in MATHML that do not appear when compiling in pdf or MATHJAX.

The compile command is:
make4ht sincosdiv.tex -f html5-common_domfilters -c ml_make4ht -l -u -s -d ./html/mathml "mathml, 3, sec-filename, fn-in, blind"

The problem arises when the macro \sin (or \cos) is followed by a parenthesis.

Second problem is the \div symbol is rendered differently when I compile in MATHML.

P.S. I do not understand these warnings and how to fix them.

[WARNING] tocid: char-def module not found
[WARNING] tocid: cannot fix section id's

The source:

\documentclass[10pt,a4paper,openright]{memoir}



\RequirePackage{amsmath, amssymb, amsthm}% amsfonts è caricato da amssymb
\RequirePackage[e]{esvect} % per i vettori
\RequirePackage{physics}   % fisica e differenziale (dd)
\RequirePackage{cancel} % per le semplificazioni
\RequirePackage[normalem]{ulem} % sottolineature
\RequirePackage[np,noaddmissingzero,autolanguage]{numprint}
\RequirePackage{mathtools} % da approfondire

\RequirePackage[greek, italian]{babel}
\usepackage{iftex}

\ifpdftex\typeout{************* PDFTeX*****************}
  \RequirePackage[T1]{fontenc}
  \RequirePackage[utf8]{inputenc}% non più necessario, ma non disturba
  \RequirePackage{stix2} % font

\else
  \ifluatex\typeout{************* LuaLaTeX *****************}
    \usepackage{fontspec}
    \setmainfont{STIX}[Ligatures=TeX]
    \usepackage[math-style=ISO]{unicode-math}
    \setmathfont{STIX Two Math}
  \fi
\fi

\RequirePackage{eurosym} % simbolo dell'euro
\RequirePackage{pifont} % simboli unicode
\RequirePackage[inline]{enumitem} % elenchi
\RequirePackage{multicol} % testo su più colonne
\RequirePackage{multirow} % tabelle con celle su più righe
\RequirePackage{quoting} % per le citazioni
\quotingsetup{font=small}
\RequirePackage{tabto} % per punti di tabulazione
\RequirePackage{microtype} % per la composizione fine
\RequirePackage[usenames, dvipsnames]{xcolor}   % gestione colori
\RequirePackage{pgfplots} % per axis
\RequirePackage{tikz}
\RequirePackage{tkz-fct} % per il disegno di funzioni
\RequirePackage{tikz-qtree} % per alberi
\usetikzlibrary{
  arrows,%
  arrows.meta,
  through,
  automata,%
  backgrounds,%
  calc,%
  circuits.ee.IEC,
  decorations.markings,%
  decorations.shapes,%
  decorations.text,%
  decorations.pathreplacing,%
  fit,%
  matrix,%
  mindmap,%
  patterns,%
  positioning,%
  intersections,%
  shapes,%
  shapes.geometric,
}
\RequirePackage{tkz-euclide} % in geometria viene usato \tkzDrawSegment

\RequirePackage[most]{tcolorbox}% per i box colorati
\RequirePackage{piton}% per i listati dei programmi
\PitonOptions{line-numbers, auto-gobble, background-color = green!15,
              splittable=3, break-lines-in-Piton, indent-broken-lines,
              }
\RequirePackage[colorlinks, hyperindex, pagebackref,
                linkcolor=RoyalBlue, filecolor=RoyalBlue,
                citecolor = black, urlcolor=RoyalBlue]{hyperref}
\RequirePackage{imakeidx}   % Indice analitico
\makeindex[options={-s matlibera.ist}, title=Indice analitico, intoc,
           columns=2]


% Insiemi numerici:
\newcommand{\R}{\mathbb{R}} % Reali
\newcommand{\IR}{{}^*\hspace{-.12em}\mathbb{R}} % Iperreali

\newcommand{\coloresem}{yellow}

\theoremstyle{plain}

\tcbset{
esemstyle/.style={
fonttitle=\bfseries\upshape, fontupper=\slshape,
arc=0mm, colback=\coloresem!5!white, colframe=\coloresem!50!black,
theorem style=plain, coltitle=\coloresem!30!black}
}

\newtcbtheorem[number within=chapter]{esempio}{Esempio}
              {esemstyle}{esem}

\newcommand{\tonda}[1]{\left( #1 \right)}


\begin{document}

\section{Error in sin(\dots) or cos(\dots)}
\begin{verbatim}
If: 
\(\sin x = a\)
then: 
\(\sin \tonda{x + \pi} = a\)

If: 
\(\cos x = a\)
then: 
\(\cos \tonda{x + 2\pi} = a\)
\end{verbatim}

If: 
\(\sin x = a\)
then: 
\(\sin \tonda{x + \pi} = a\)

If: 
\(\cos x = a\)
then: 
\(\cos \tonda{x + 2\pi} = a\)


It is okay so far.


\begin{verbatim}
If: 
\(\sin x = a\)
then: 
\(\sin (x + 2\pi) = a\)

If: 
\(\cos x = a\)
then: 
\(\cos (x + 2\pi) = a\)
\end{verbatim}

If: 
\(\sin x = a\)
then: 
\(\sin (x + 2\pi) = a\)      % Line giving error.

If: 
\(\cos x = a\)
then: 
\(\cos (x + 2\pi) = a\)      % Line giving error.

\begin{verbatim}
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename     Line    Message
[ERROR]   htlatex: ./sincosdiv.tex      145      Extra }, or forgotten \right.
[ERROR]   htlatex: ./sincosdiv.tex      145      Missing } inserted.
[ERROR]   htlatex: ./sincosdiv.tex      150      Extra }, or forgotten \right.
[ERROR]   htlatex: ./sincosdiv.tex      150      Missing } inserted.
\end{verbatim}


\section{Symbol div rendered differently}

\begin{verbatim}
\(A \div B ~ \rightarrow ~ Q \text{ and } R 
  \qquad \text{ if } 
  Q \cdot B + R = A\)
\end{verbatim}

\(A \div B ~             % Symbol \div is rendered differently in MATHML.
  \rightarrow ~ Q \text{ and } R 
  \qquad \text{ if } 
  Q \cdot B + R = A\)

\end{document}

Thank you for your attention.

Daniele

@michal-h21
Copy link
Owner

Hi Danielle, it seems to be caused by the physics package. I will take a look at it later, but both issues go away when I remove it. It seems that it redefines lot of math commands in a way which doesn't work with TeX4ht.

@michal-h21
Copy link
Owner

It seems this file, physics.4ht should fix it:


\DeclareDocumentCommand\argopen{s}{} % Special open grouping for argument of a function
\DeclareDocumentCommand\argclose{s}{} % Special close grouping for argument of a function
\Hinput{physics}
\endinput

Regarding the \div command, it seems that physics redefines it to this symbol. I get the same result even in the PDF output. The original symbol is available as \divisionsymbol.

@danielezambelli
Copy link
Author

I removed the "physics" package from my project.

Thank you.

@michal-h21
Copy link
Owner

The fix didn't help?

@danielezambelli
Copy link
Author

The fix works for sin(...) and cos(...) then I had other problems with tan(...) and preferred to directly implement the two commands I needed (\dd and \dx) without loading the whole package.

I do not know too much about LaTeX, and sometimes I find solutions that are not the best.

@michal-h21
Copy link
Owner

In general, I think it is better to not load too many packages, as it increases the compilation time significantly, and it also can lead to clashes between command definitions. So it is best if you were able to create custom commands that work for you.

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