首页 > 解决方案 > MathJax:如何使数学可复制?

问题描述

我正在使用 MathJax 在 HTML 文档中显示一些方程式。下面的代码片段解释了我想要做的事情:

<!DOCTYPE html>
<html>

<head>
    <title>Math in HTML</title>
    
    <meta charset="utf-8">
    <script>
    MathJax = {
      tex: {
        inlineMath: [['$', '$'], ['\\(', '\\)']]
      },
      svg: {
        fontCache: 'global'
      }
    };
    </script>
    <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
    <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
</head>

<body>
        <h1>Mathematic equations</h1>
        <p>I cannot select this equation:
                
                $$\intop_0^1f(x)dx=\pi$$
            
            nor this one $x^2 + 3x - 2 = \zeta$.
        </p>
        
        <p>I would like that when someone copy-pastes the previous paragraph he/she would get:
        <code>I cannot select this equation:
                
                $$\intop_0^1f(x)dx=\pi$$
            
            nor this one $x^2 + 3x - 2 = \zeta$.</code>
</body>

</html>

基本上我想让数学可以选择,并在复制到剪贴板以获取 Latex 代码时。这可能吗?

标签: htmlmathjax

解决方案


推荐阅读