\newenvironment for custom definitions

Hello all,

I was recently made aware that one can define new commands in TiddlyWiki using \def. Now I want to take a step ahead and define my custom environments that can be used fluently across my tiddlers . That is I want to use \newenvironment of LaTeX within tiddlywiki in the config to use it anywhere if need be.

Is there a way to do this? If not do you have some hack for this? Like create a template tiddler with some arguments that can be called to invoke an enviroment ?

Thank you very much your time!

Regards,
Pious Heretic

Welcome!

You have been misinformed. At least as far as I know.

What you probably mean is that you can define macros, which uses the \define pragma. See the docs for more info.

With that said, there is currently development going on to extend this functionality, see the announcement. I urge you to check this out and ask further questions about how it can integrate with LaTeX because LaTeX is fairly popular here so your use case may be of value to know about.

Apologies and bear with me if I sound too naive or my statements do not make sense. I’m a new user of TW and I’m not yet completely exposed about how the system works . I am trying to equip TW as my all-round note taking app.

Some more context about my question:

Katex has some support to define macros for math environment as shown below. What I want is to extend this to also include a macro for lets say a bmatrix or pmatrix or align environment. So that when I want to use this environment I can just type the macro. This is possible in LateX.

I looked at the macros page you linked. This speaks about a general macro definition across all tiddlers right? Like a function you can call with some parameters. Please correct me if I’m wrong. Although I would deep dive into the documentation a bit later. I need your two cents on this if this is something I can spend some serious time on. I see this can be some how used to resolve my situation. I can create a tiddler with macro tag that has some latex in it and call it each time I would like to use this environment? It seems a bit sternous but is there an alternative to do this directly within KateX plugin ?

This is how I was able to define some macros for simple commands

Thanks for the second time!

First off; I’ve never used Latex or the Latex plugin so I’m not really qualified to answer and I hope someone else can give better information.

You’re right.

So, this is a general reply about “plugins”. Maybe all “Katex plugins” feature some kind of built in build-a-macro-features, I have no idea but assuming the TW version behaves like any other plugin then, yes, you would separately create a macro which is a global function. It is not overly difficult. The tiddler needs the $:/tags/Macro tag and to follow some syntactic rules therein. The macros can invoke Katex commands, etc.

But, I’m sure someone who actually uses the Katex plugin can give a more satisfactory answer. Don’t hesitate to ask more, even if I personally can’t add much more.

1 Like