<!-- only use katex -->\n<!DOCTYPE html>\n<html>\n <head>\n <link\n rel=\"stylesheet\"\n href=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css\"\n />\n <script\n defer\n src=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js\"\n ></script>\n <script\n defer\n src=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/mhchem.min.js\"\n ></script>\n <script\n defer\n src=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js\"\n onload=\"renderMathInElement(document.body);\"\n ></script>\n </head>\n <body>\n <span>\n $$\\ce{N2 + 3H2 <=>T[High temperature Pressurized][Catalyst] 2NH3}$$\n </span>\n </body>\n</html>Hello,
\nHow can I use mhchem macros in the options to parse chemical formulas properly? I saw in the official documentation that it can be directly included, but I am having trouble getting it to work with Vue 3. Could you please provide me some assistance in making \"use macros with mhchem\" function correctly? I greatly appreciate your help.
","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"thanks all. it is working. see here
","upvoteCount":0,"url":"https://github.com/KaTeX/KaTeX/discussions/3915#discussioncomment-8043120"}}}-
<!-- use macros with mhchem -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Marked with mhchem</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
/>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/mhchem.min.js"></script>
</head>
<body>
<div id="content"></div>
<script>
const options = {
throwOnError: false,
displayMode: true,
macros: {
'\\ce': '\\mhchem{#1}',
},
}
const str =
'\\ce{N2 + 3H2 <=>T[High temperature Pressurized][Catalyst] 2NH3}'
document.getElementById('content').innerHTML = katex.renderToString(
str,
options
)
</script>
</body>
</html><!-- only use katex -->
<!DOCTYPE html>
<html>
<head>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
/>
<script
defer
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
></script>
<script
defer
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/mhchem.min.js"
></script>
<script
defer
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"
onload="renderMathInElement(document.body);"
></script>
</head>
<body>
<span>
$$\ce{N2 + 3H2 <=>T[High temperature Pressurized][Catalyst] 2NH3}$$
</span>
</body>
</html>
Hello, How can I use mhchem macros in the options to parse chemical formulas properly? I saw in the official documentation that it can be directly included, but I am having trouble getting it to work with Vue 3. Could you please provide me some assistance in making "use macros with mhchem" function correctly? I greatly appreciate your help. |
Beta Was this translation helpful? Give feedback.
-
|
Your macro |
Beta Was this translation helpful? Give feedback.
thanks all. it is working. see here