own commands in KaTeX plugin

266 views
Skip to first unread message

Maaaaaaaaaaaaaaartin

unread,
Jan 22, 2017, 2:31:47 AM1/22/17
to TiddlyWiki
Dear all,

I need to define my own LaTeX commands to efficiently use the KaTeX plugin. Is there a way to do so? Thanks!

Martin

Maaaaaaaaaaaaaaartin

unread,
Jul 27, 2017, 4:55:32 AM7/27/17
to TiddlyWiki
Any help with that? Thanks! Martin

Ste Wilson

unread,
Jul 27, 2017, 7:57:37 AM7/27/17
to TiddlyWiki
I think there was a thread on this not too long ago..

Ste Wilson

unread,
Jul 27, 2017, 8:37:20 AM7/27/17
to TiddlyWiki

Mark S.

unread,
Jul 27, 2017, 12:20:41 PM7/27/17
to TiddlyWiki
I think you're asking about using the \newcommand ??

Looking at the Katex library upon which the plugin is based, it kind of looks like \newcommand isn't there.

A different approach might be to provide substitutions via TW macros. See:

https://groups.google.com/forum/#!searchin/tiddlywiki/katex%7Csort:date/tiddlywiki/vYBfUAriyRU/UzyxnDxZAAAJ

The original request was to do substitution in the text. Looking at the plugin code, I think that it might be possible to rewrite it so that it makes use of a data dictionary, allowing a user to define their own substitutions. But that would still not be quite the same as defining new commands that take new parameters.

Mark

Martin Genet

unread,
Jul 27, 2017, 12:49:23 PM7/27/17
to 'Mark S.' via TiddlyWiki
Thanks Mark! Martin
--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/iHgkKgMHfQo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/47f96ca8-746c-4dee-bb9c-01be49c182e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

dva...@gmail.com

unread,
Dec 16, 2017, 11:42:55 AM12/16/17
to TiddlyWiki
Hi,

I found that that can be done by just putting your custom commands in a regular tiddler, in math mode. For e.g. my tiddler is titled "Latex Definitions" and has the following content:

%custom environments and fonts
$\newcommand{\beq}{\begin{equation}}$
$\newcommand{\eeq}{\end{equation}}$
$\newcommand{\bea}{\begin{eqnarray}}$
$\newcommand{\eea}{\end{eqnarray}}$
$\newcommand{\mx}{\mbox}$
$\newcommand{\mt}{\mathtt}$
$\newcommand{\mf}{\mathbf}$
$\newcommand{\mb}{\mathbb}$

%text
$\newcommand{\ie}{{\it{i.e.}~\}}$
$\newcommand{\eg}{{\it{e.g.}\}}$
$\newcommand{\hs}{\hspace{5mm}}$
$\newcommand{\vs}{\vspace{5mm}\\}$

%math
$\newcommand{\vectb}[1]{\boldsymbol{#1}}$
$\newcommand{\vecta}[1]{\overrightarrow{#1} }$
$\newcommand{\expect}[1]{\langle #1\rangle}$
$\newcommand{\innerp}[2]{\langle #1 \vert #2 \rangle}$
$\newcommand{\bra}[1]{\langle #1 \vert}$
$\newcommand{\ket}[1]{\vert #1 \rangle}$
$\newcommand{\supersc}[1]{$^{\textrm{#1}}$}$
$\newcommand{\subsc}[1]{$_{\textrm{#1}}$}$

And that works just fine. Only problem is this tiddler has to be loaded at startup and I still can't figure out how to do that. TW 2.x had the SystemTiddler tag, but I'm not sure how to do that in TW 5.x. So I have to manually load the tiddler and then the definitions work everywhere.

Hope that helps,

Best,

Deepak

Diego Mesa

unread,
Sep 3, 2019, 1:41:17 PM9/3/19
to TiddlyWiki
Hello,

Did you (or anyone) ever find a solution to this?
Reply all
Reply to author
Forward
0 new messages