michael-brade / LaTeX.js

JavaScript LaTeX to HTML5 translator
https://latex.js.org
MIT License
736 stars 58 forks source link

\newcommand. doesn't work #134

Open itworkman opened 2 years ago

itworkman commented 2 years ago

When you input "\newcommand{\yourcommand}{your content}, like this:

\documentclass{article}

\usepackage{comment, multicol} \usepackage{hyperref}

\usepackage{calc,pict2e,picture} \usepackage{textgreek,textcomp,gensymb,stix} \newcommand{\yourcommand}{your content}

.......

then error below:

ERROR: Parsing failure:

line 8 (column 1): tcomp,gensymb,stix}\n\newcommand{\yourcom ----------------------------------------^ expected \begin{document}

It looks like it doesn't recognize the "\newcommand"

I try to search the "\newcommand" definition from latex.js

line 38217:

var newcommand = (context, existsOK, nonexistsOK) => {
  var arg = context.consumeArg().tokens;

So how to fix that. We need fix the \newcommand

Carlos, Thanks

oreoluwa-bs commented 9 months ago

I believe you have to create your own custom macro instead