2017-03-11 5 views
0

MathJax 수식을 표시하는 데 어려움을 겪고 있습니다. 여기에 최소한의 코드를 살펴 줄 것이다 CodePen은 다음과 같습니다ASP.Net 및 레이블 컨트롤이있는 MathJax

<script type="text/javascript" 
    src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> 
</script> 
<script type="text/x-mathjax-config"> 
     MathJax.Hub.Config({ 
     tex2jax: {inlineMath: [["$","$"],["\\(","\\)"]]} 
     }); 
    </script> 

<div style="position:absolute;width:100%;background-color: #99FF99" class="auto-style1"> 
     Background Calculations</div> 
<br /><br /> 
    <table class="auto-style2"> 
     <tr> 
      <td class="auto-style8">Effective <strong><span class="auto-style7">Cases Produced</span></strong>:</td> 
      <td class="auto-style9"></td> 
      <td></td> 
      <td>$$Cases Produced = {\color{red}{\textit{Filled Packages}} \over \color{blue}{\textit{Trays per Case}}}$$</td> 
      <td>$$ = {\color{red}{\textit{<asp:Label ID="Label5" runat="server" Text="######"></asp:Label>}} \over \color{blue}{\textit{<asp:Label ID="Label6" runat="server" Text="###"></asp:Label>}}}$$</td> 
      <td></td> 
      <td></td> 
     </tr> 

    </table> 

수동으로 입력 한 수식이 잘 작동합니다. 그러나 Label 컨트롤을 사용하여 수식을 얻지 못하는 것 같습니다.

<td>$$ = {\color{red}{\textit{<span id="Label1">######</span>}} \over \color{blue}{\textit{<span id="Label1">###</span>}}}$$</td> 

제가 생각하기 때문에 어떻게 ASP.NET은 SPAN로가 아닌 실제 값 레이블을 렌더링하고의, - MathJax 그것을 알아낼 수 없습니다 : 그것은이 같은 텍스트 값을 렌더링하기 때문에 주로, 나는 생각한다 아웃?

이 작업을 수행하려면 어떻게해야합니까?

+0

죄송합니다. codepen을 게시 할 수 없지만 기본적으로 위와 동일합니다. – Andrew

+0

미래의 노트 : cdn.mathjax.org는 수명이 거의 다되어 가고 있습니다 (cf. https://www.mathjax.org/cdn-shutting-down/. –

답변

0

내가 발견 한 것은 레이블 대신 리터럴을 사용하는 것이 길이다. 코드 변경 내용은 다음과 같습니다.

<table class="auto-style2"> 
    <tr> 
     <td class="auto-style8">Effective <strong><span class="auto-style7">Cases Produced</span></strong>:</td> 
     <td class="auto-style9"></td> 
     <td></td> 
     <td>$$Cases Produced = {\color{red}{\textit{Filled Packages}} \over \color{blue}{\textit{Trays per Case}}}$$</td> 
     <td>$$ = {\color{red}{\textit{<asp:Literal ID="Literal1" runat="server" Text="######"></asp:Literal>}} \over \color{blue}{\textit{<asp:Literal ID="Literal2" runat="server" Text="###"></asp:Literal>}}}$$</td> 
     <td></td> 
     <td></td> 
    </tr> 

</table> 
+0

문맥에서, MathJax의 TeX 파서는 HTML 태그에서 멈출 것이다, cf. http://docs.mathjax.org/ko/latest/tex.html#tex-and-latex-in-html-documents. 도움이 될만한 '\ cssId {MYID} {math}'와 같은 비표준 매크로가 있습니다 (cf. http://docs.mathjax.org/en/latest/tex.html#html. –