diff --git a/docs/docs/markdown.md b/docs/docs/markdown.md index 071ba9481c1..70108d4d9d2 100644 --- a/docs/docs/markdown.md +++ b/docs/docs/markdown.md @@ -103,6 +103,33 @@ This will be rendered as: ![alt-text](https://learn.microsoft.com/en-us/media/learn/not-found/learn-not-found-light-mode.png?branch=main) +## Math Expressions + +Docfx supports [LaTeX formatted math expressions](https://en.wikibooks.org/wiki/LaTeX/Mathematics) within markdown using [MathJax](https://docs.mathjax.org/en/latest/#). + +> [!NOTE] +> Math expressions is only supported in the `modern` template. + +To include a math expression inline with your text, delimit the expression with a dollar symbol $. + +```md +This sentence uses `$` delimiters to show math inline: $\sqrt{3x-1}+(1+x)^2$ +``` + +This sentence uses `$` delimiters to show math inline: $\sqrt{3x-1}+(1+x)^2$ + +To add a math expression as a block, start a new line and delimit the expression with two dollar symbols $$. + +```md +**The Cauchy-Schwarz Inequality** + +$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$ +``` + +**The Cauchy-Schwarz Inequality** + +$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$ + ## Include Markdown Files Where markdown files need to be repeated in multiple articles, you can use an include file. The includes feature replace the reference with the contents of the included file at build time. diff --git a/samples/seed/articles/markdown.md b/samples/seed/articles/markdown.md index 602ad8c1aeb..95c2e541b9a 100644 --- a/samples/seed/articles/markdown.md +++ b/samples/seed/articles/markdown.md @@ -140,6 +140,18 @@ The example highlights lines 2, line 5 to 7 and lines 9 to the end of the file. [!code-csharp[](media/Program.cs?highlight=2,5-7,9-)] +## Math Expressions + +This sentence uses `$` delimiters to show math inline: $\sqrt{3x-1}+(1+x)^2$ + +**The Cauchy-Schwarz Inequality** + +$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$ + +This expression uses `\$` to display a dollar sign: $\sqrt{\$4}$ + +To split $100 in half, we calculate $100/2$ + ## Tabs Tabs enable content that is multi-faceted. They allow sections of a document to contain variant content renderings and eliminates duplicate content. diff --git a/src/Microsoft.DocAsCode.MarkdigEngine.Extensions/MarkdownExtensions.cs b/src/Microsoft.DocAsCode.MarkdigEngine.Extensions/MarkdownExtensions.cs index 92b10a1881d..91303cae738 100644 --- a/src/Microsoft.DocAsCode.MarkdigEngine.Extensions/MarkdownExtensions.cs +++ b/src/Microsoft.DocAsCode.MarkdigEngine.Extensions/MarkdownExtensions.cs @@ -14,7 +14,7 @@ public static class MarkdownExtensions public static MarkdownPipelineBuilder UseDocfxExtensions(this MarkdownPipelineBuilder pipeline, MarkdownContext context) { return pipeline - //.UseMathematics() + .UseMathematics() .UseEmphasisExtras(EmphasisExtraOptions.Strikethrough) .UseAutoIdentifiers(AutoIdentifierOptions.GitHub) .UseMediaLinks() diff --git a/templates/modern/layout/_master.tmpl b/templates/modern/layout/_master.tmpl index 31e7092a06c..f7473718eb3 100644 --- a/templates/modern/layout/_master.tmpl +++ b/templates/modern/layout/_master.tmpl @@ -25,13 +25,21 @@ {{#_enableSearch}}{{/_enableSearch}} {{#docurl}}{{/docurl}} + + {{/redirect_url}} {{^redirect_url}} - +