Hello. Is it possible to get a gutenberg block inside paragraph? Using shortcode without preview is so annoying. I need a preview for inline shortcode.
]]>How to render KaTeX on comment section? It only works on the article.
]]>The may be the dumbest question ever asked.
I am working on math coursework, and trying to copy and paste equations into WordPress. The text retains its formatting — bold, headings, list items, etc.
When I paste in the equations, the characters are replaced with ?, even with Katex loaded. I’ve seen instructions for actually typing in the equations, with shortcodes before each one, but I am simply pasting them in.
What am I doing wrong? How can I copy and paste the equations into WordPress?
Hi Thomas! Thanks for making such an amazing plugin!
It seems one common problem others and I have ran into loading the katex scripts conditionally
currently the plugin checks ONLY posts types for the short code before enqueuing the katex script on that page.. a lot of users would also like to use katex in custom fields as well… but the only way (currently) is to enqueue the katex script globally..
in my case, multiple acf fields contained the the [katex][/katex] shortcode.. others might be using custom fields from other plugins like an LMS or quiz platform…
i used a simple fix is to just have the code additionally check any custom feilds for any instances of [katex] shortcode and then enqueue the katex script on that page.
ill post the code that worked for me below and hopfuilly others can use it… and maybe it can included into the plugin natively.
// for checking custom fields
function has_katex_shortcode_in_acf_fields($post_id) {
// Get all custom fields of the post
$custom_fields = get_post_custom($post_id);
foreach ($custom_fields as $key => $values) {
foreach ($values as $value) {
if (strpos($value, '[katex') !== false) {
return true; // Found the shortcode
}
}
}
return false;
}
Enqueuing logic … (note this is just general code soltion.. will need to tweak a bit based on plugins Enqueuing function paramaters, etc.
function enqueue_katex_for_acf_fields() {
global $post;
if (is_singular('your_custom_post_type') && has_katex_shortcode_in_acf_fields($post->ID)) {
// plugins ensuing logic.
}
}
add_action('wp_enqueue_scripts', 'enqueue_katex_for_acf_fields');
Again just to clarify im using this for ACF fields and it worked for me but might be different for others.
]]>I love the katex plugin for wordpress. I use it with Gutenberg blocks and it works nice.
Except for one thing: I want to make html-links in my equations and I cannot figure out how. \href only prints a red href.
I have googled and found that I need to set trust to true in the options, but cannot figure out how to do that in wordpress. Can I do that in javascript somehow?
]]>Hi,
We’re running into an issue unloading KaTeX scripts from pages where we are not using the shortcode. We’ve tried the “Load KaTeX assets conditionally”, but then it does not load the assets when we need them.
Assets loaded conditionally enabled: https://share.getcloudapp.com/Z4uGgJn9
Assets loaded conditionally disabled:
https://share.getcloudapp.com/04uvB0vm
We’ve also tried using Perfmatters to unload KaTeX from the pages where it’s not in use, but there’s still one script loading from somewhere on every page:
function _katexRender(rootElement) { const eles = rootElement.querySelectorAll(“.katex-eq:not(.katex-rendered)”); for(let idx=0; idx < eles.length; idx++) { const ele = eles[idx]; ele.classList.add(“katex-rendered”); try { katex.render( ele.textContent, ele, { displayMode: ele.getAttribute(“data-katex-display”) === ‘true’, throwOnError: false } ); } catch(n) { ele.style.color=”red”; ele.textContent = n.message; } } } function katexRender() { _katexRender(document); } document.addEventListener(“DOMContentLoaded”, function() { katexRender(); // Perform a KaTeX rendering step when the DOM is mutated. const katexObserver = new MutationObserver(function(mutations) { [].forEach.call(mutations, function(mutation) { if (mutation.target && mutation.target instanceof Element) { _katexRender(mutation.target); } }); }); const katexObservationConfig = { subtree: true, childList: true, attributes: true, characterData: true }; katexObserver.observe(document.body, katexObservationConfig); });
Any tips for either correcting the load assets conditionally option or removing the script above from the pages where the KaTeX shortcode is not in use? Thank you!
]]>Hi,
Thanks for the great application!
However, I have two problems:
Hello,
This plugin allows the creation of Gutenberg block to allow LaTeX code to be seen instantly and that’s very nice!
I wonder if you have ever thought about creating the functionality of this, but directly in a new paragraph block of Gutemberg.
E.G. you type [latex] x^2=x [/latex] in a new paragraph block of Gutemberg.
When you close the last ‘]’ symbol of ‘[/latex]‘ some javascript see this and auto-render the [latex] x^2=x [/latex], or create some bubble that shows the latex rendering. That could be awesome.
Let me see if I am clear on my suggestion and if it can be done.
Thanks
]]>Hi there,
thank you for this wonderful plugin. It works like a charm in most scenarios. However, it doesn’t work when inserted as quastion in the plugin HD Quiz. Then Latex is not rendered. I think the shortcode is not even recognized.
Could you please help out?
Thank you!
]]>Do you support Asymptote drawing?
]]>Dear Mr. Churchman,
I personally prefer Katex to MathJax for my website, but Katex is added to every webpage even though most pages do not have any math displayed on them. This is also true for MathJax, but this problem can be eliminated by only having MathJax loaded for webpages displaying math with the following command sequence for displaying a Tek equation:
<script type="text/javascript" id="MathJax-script" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js">;
</script>
<div style="font-size:22px">$$x = {-b pm sqrt{b^2-4ac} over 2a}.$$</div>
If you notice, MathJax is loaded from the https://cdn.jsdelivr.net server for every instance on a page when it is needed. Can this also be done for Katex? If so, what is the command sequence for the Quadratic Equation shown above to accomplish this?
Thanks in advance for your assistance.
Respectfully,
Scott
]]>Hello. Is there a way to put a preamble that will work for any formula sitewide? For instance, I’d like to create custom Latex commands using \def. Thanks.
]]>Hello, I have a feature request. I think it might be interesting to add the ability of having an instant preview of the inline Latex code, just like the already available preview on Gutenberg blocks.
I’m using in-line Latex heavily, and that feature would really improve the readability of what I am writing, avoiding frequent previews of the whole post. Maybe others have this same need.
The old Mathjax based plug-in “Insert Math” provided the ability to get a preview of each formula on a Window. Maybe something like that is not that easy to implement in Gutenberg editor, but would be awesome for in-line latex.
Either way, excellent plug-in. Just started to use it yesterday and I’m quite enthusiast. Thanks!
Hello, I am using Tutor LMS plugin for my course site. Now I want to use the Katex plugin for my math algorithm and calculations.
But it is showing katex is not defined.
Thank you in advance for the support.
]]>Hi! I run a calculators database website and I’m using tooltips via Tooltips Pro by Tomas Zju for showing tooltips for frequently occurred special terms like RPN or leading zeroes, so I found your plugin an excellent tool for putting math formulas into such tooltips. Unfortunately, that plugin is made a way it puts all tooltip content including code into a long JS string and adds it into the document programmatically. So, all content becomes escaped via backslashes and then Katex JS code doesn’t recognize special codes like \sqrt anymore and processes only a part of the code. Could that be possible to add support for escaped strings or update the way the code is processed on the client-side to make sure it supports JS-generated content? Thanks.
The example is available via the provided link.
]]>Hello,
I’ve figured out I can use Katex in the elementor editor by enclosing my equations within [katex] [/katex]. I then have to preview the page to see them rendered. I wonder if there is a way to have the Katex block be available in the list of elementor blocks, like how it is available in Gutenberg.
Any suggestions?
Thanks
Hi,
Maybe I didn’t search long enough, but I didn’t found in https://katex.org/docs/supported.html
how to get that kind of symbol :
This one has been created using the dsfont package, but any other solution would be fine.
Thank you for your help.
]]>Hi there,
I am the author of a mathematical blog (all written in french) :
https://math-os.com
which is heavily using the plugin QuickLateX.
I am about to switch to KaTeX but not yet sure …
I wouldn’t like to have to modify too many things in the existing articles.
My question : do I have to enclose each tex expression in [katex] … [/katex] or is possible to deal with $ … $ ?
]]>Hi Thomas,
First, TY VERY MUCH for your very useful plugin!
All is perfect on my Learndash website except one little thing that is crucial for my students.
The [latex] shortcodes work everywhere (including in quizzes) but don't work on the quiz statistics report page (the wpProQuiz_modal_window).
I have tried all the solutions you described in this forum and all the options offered by your plugin, nothing worked.
Could you please help me with this issue?
TY very much!
Hi @beskhue
I have written alot of latex using mathjax shortcodes which are \( ….. \) for inline and \[ …. \] for display equations. If you add rendering support for these two shortcodes, all users who have written for mathjax can use your plugin instead of Mathjax.
Regards,
In rtl pages katex renders equations from rtl direction and they will not be readable.
For instance f(x)=2x will be rendered 2x=f(x)
This is a simple example but for complex equations and expressions they are not even readable.
Is there any solution that katex does not obey site direction and always should render equations in ltr direction just like what mathjax is doing?
I am using the following expressions, which renders fine on the editor on the ketex.org home page. Although when I try to use it with [katex] shortcode I get the following error.
\begin{CD} 100 @>-1>> 99 @>-3>> 96 @>-1>> 95 @>-3>> 92 @>-1>> 91 @>-3>> \boxed{88} \end{CD}
KaTeX parse error: {CD} can be used only in display mode.
May I know what could be the issue, please?
]]>Hi,
Geting the following error..
Notice: Undefined variable: option_load_assets_conditionally in /home/newtontw/public_html/wp-content/plugins/katex/scripts/resource.php on line 85
I use Katex and CM Tooltip Glossary in my blog. Anything is good but Katex in tooltip.
In tooltip, Katex does not render – it shows only raw Katex’s text (without [latex] and [/latex]).
Katex works well in pages and posts (except tooltip).
Help me.
Thanks!
]]>Is there any way I can flush left or right for blocks?
]]>I had been using WP QuickLaTeX, which provided for numbering of equations. But that plugin no longer works with the latest version of WP. I don’t see any mention in this forum about using equation numbers in KaTeX. Does anyone know if \tag{value} or \label{<label>} will work in KaTeX? Or lacking that, does anyone have a DIY hack to achieve numbering? Thanks.
]]>I get an error when trying to view this page on certain browsers, where any Katex shows up as “katex is not defined”.
The issue shows up on Chrome (desktop) and MS Edge, but not on Chrome (mobile) or Firefox (desktop and mobile).
I am using the Iknow theme (version 1.2.6), WordPress version 5.7.1, and the katex plugin version 2.1.2.
The issue appears in both Katex Gutenberg blocks and the Katex shortcode within text.
]]>First of all, thank you for developing this great plugin! I use it extensively for displaying equations on my website.
I’ve recently noticed an issue with the Katex Gutenberg block which occurs when the block is placed within a “Group” or “Columns” container with other blocks. When editing the other blocks within the same container (for example a Paragraph), all Katex blocks within that specific container will auto-expand to show both the code and equation once you start typing in any block in the container. This can be distracting since it causes all the text on the page to jump up and down when the Katex blocks expand and minimise. The expected behaviour would be for the Katex blocks to remain minimised until only that specific block has been selected and is in focus.
This issue only occurs within each specific “Group” or “Columns” container, and does not appear in Katex blocks which are not placed in a container.
KaTeX version: 2.1.2
Wordpress version: 5.7.1
Browsers: Firefox, Chrome
I’m making quizzes with Learndash plugin for wordpress. Katex does a fine job but there are a few issues.
When quizzes are set to randomize question order and when I want to display feedback for the questions, the shortcode does not render Latex.
I’ve reached out to Learndash developers and below is what they had to say about it.
Here is the link to a page where katex renders.
https://orientationbatistonparcours.srv11.createurdimage.fr/quizzes/derivees-niveau-3/
And another one where Katex does not render
https://orientationbatistonparcours.srv11.createurdimage.fr/quizzes/derivees-piste-verte/
____________copy paste from learndash support_______
Our developers dug into this deeper and the issue is coming from the Katex plugin and how they render the shortcode.
Since our quizzes are being generated via Ajax for the most part, the shortcode is not rendering correctly. More specifically, this conditional is blocking the shortcode from generating: https://monosnap.com/file/qEqxCaZJi77ulw6VPbD6bVpRfOMn0I
So this is why when the questions are being loaded via AJAX the [katex] shortcode is not registered with WP and thus not setup to handle the parsing of the content.
It does seem like the Katex plugin author is aware of this to some extent, so it would be more appropriate for them to resolve it via their plugin.
]]>Hi, is it possible to use the Katex block in a ACF? (not Gutenberg)
]]>