使用MathJax我需要\ ensuremath的解决方案

时间:2016-04-17 20:43:35

标签: latex mathjax

我在几个项目中使用MathJax,它通常像魅力一样。

然而,今天,在使用以下对齐环境翻译现有LaTeX文档的一部分时,我遇到了一个问题:

Block sign = world.getBlockAt(signLoc); // Get the block
sign.setType(Material.WALL_SIGN); // Set the type to "WALL_SIGN", now it's BlockState is an instance of "Sign"

BlockState signState = sign.getState(); // Get the general state

if (signState instanceof org.bukkit.block.Sign) { // Make sure the sign block really does have the "Sign" BlockState (this isn't really necessary, more of a double check)
    org.bukkit.block.Sign signBlock = (org.bukkit.block.Sign) signState; // Note that this is the org.bukkit.block.Sign interface
    signBlock.setLine(0, "Hello"); // Set the first line
    signBlock.setLine(1, player.getName()); // Set the second line
    if (signState.getData() instanceof org.bukkit.material.Sign) { // Now get the "MaterialData" from the BlockState...
        org.bukkit.material.Sign signMaterialData = (org.bukkit.material.Sign) signState.getData(); // And cast it to org.bukkit.material.Sign
        signMaterialData.setFacingDirection(BlockFace.WEST); // Use this to change the direction of the sign, in this case WEST (sign is placed + X direction of player)
    }
    signBlock.update(); // Update the sign's state
}

使用LaTeX呈现的结果是这样的(对于荷兰文本抱歉; - ):

enter image description here

align-environment基本上是SQL> create or replace function erwin return number<12>; is horse number<12>; begin select sal into horse from emp where empno='7900'; return horse; end; / 上下文,因此如果您需要 text ,则需要将该文本用\begin{align} & (\lambda x.(\lambda y.(\lambda z.xyz)))abc \\ = & \text{\{ impliciete toepassing expliciet maken \}} \\ & (((\lambda x.(\lambda y.(\lambda z.xyz)))a)b)c \\ = & \text{\{ \ensuremath{\beta}-reductie, substitutie van \ensuremath{x}door \ensuremath{a}\}} \\ & ((\lambda y.(\lambda z.ayz))b)c \\ = & \{\text{\ensuremath{\beta}-reductie, \ensuremath{y\,:=b}}\} \\ & (\lambda z.abz)c \\ = & \text{\{ \ensuremath{\beta}-reductie, \ensuremath{z\,:=c}} \\ & abc \\ \boxed{} \end{align} 括起来。但是当你需要在那个文本中再次使用数学符号时,你可以通过用math括起数学来逃避\text{...}上下文。

MathJax的呈现方式如下:

enter image description here

Mathjax中心一切都无所谓,这是我可以用CSS处理的东西。但是text的渲染是一个问题。显然MathJax doesn't support \ensuremath{...},但我想不出一个可行的解决方法,我可以在\ensuremath - 上下文中使用数学符号。

理想情况下,我希望有一个使用替代LaTeX构造的解决方案(因此交叉列表)

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

您应该使用$...$\(...\)代替\ensuremath{...}。这对我来说似乎更自然,即使在LaTeX本身(因为\ensuremath实际上是设计用于可能在文本和数学模式中使用的宏)。

所以你可以做到

\begin{align}
  & (\lambda x.(\lambda y.(\lambda z.xyz)))abc \\
= & \{\text{ impliciete toepassing expliciet maken }\} \\
  & (((\lambda x.(\lambda y.(\lambda z.xyz)))a)b)c \\
= & \{\text{ $\beta$-reductie, substitutie van $x$door $a$ }\} \\
  & ((\lambda y.(\lambda z.ayz))b)c \\
= & \{\text{ $\beta$-reductie, $y:=b$ }\} \\
  & (\lambda z.abz)c \\
= & \{\text{ $\beta$-reductie, $z:=c$ }\} \\
  & abc \\ \boxed{} \end{align}

我还将\{\}放在\text{}之外,但如果您愿意,可以在内部进行。

中心可能是由于页面上的CSS,因为MathJax默认左对齐这些。