Thanks, this is very useful!
I played around with this a little and found that there is actually no need 
to change the code of Katex. It is much better to use the <$latex> commands 
that Katex provides. There is a small issue that I actually found to be a 
benefit. Namely, Katex uses $$ syntax for both inline and displayed 
equations, which one it uses depends on whether there are any linebreaks. 
However, I prefer to have a choice (sometimes inline equations tend to be 
long so that it is better to write them on multiple lines). Here are my 
commands:
\define tx(text:"",displayMode:"false",
  var1:"\overline{X}",
  R:"\mathbb{R}",
  partition:"\mathcal{P}"
)
  <$latex text="$text$" displayMode="$displayMode$"></$latex>
\end
\define tex(text:"") 
  <<tx "$text$" displayMode:true>>
\end
So, <<tx "$x \in R$">> is an inline equation whereas <<tex "x \in $R$">> is 
a displayed equation, regardless of whether there are any linebreaks.

I also checked the number of variables that the approach supports and there 
were absolutely no problems with twenty variables, which is enough for me 
(for one project).

There are still a few things that I would prefer to improve upon. First, it 
would be nice to be able to define commands with arguments. For example, in 
LaTeX I like to define \newcommand{\pd}[2][]{\frac{\partial #1}{\partial 
{#2}}}, so that $\pd{f(x,y)}{x}$ is the partial derivative of $f$ wrt $x$. 
Second, it would be excellent to be able to redefine the command syntax, so 
that I could copy the text between tiddlyWiki and LaTeX. Any ideas?
Best regards,
Tom

On Sunday, July 16, 2017 at 2:34:29 AM UTC+2, Mark S. wrote:
>
> This is a little discussion about a method that might get you at least 
> closer to where you want.
>
> The problem with the implementation of Katex on TW5 is the choice of $$ to 
> indicate latex is about to begin. This causes all sorts of havoc with the 
> TW macros, because TW macros use $ and $( to indicate the start of a 
> parameter. But, if you make a couple very tiny changes to the Katex plugin, 
> you could use, for instance, %% to indicate the start of latex formatting.
>
> Once you make this change, you can then write a macro like this:
>
> \define latex(text:"",pi:"\pi",xi:"\xi",infty:"\infty",int:"\int",hat:
> "\hat")
> %%
> $text$
> %%
> \endEnter code here...
>
> In this example, I've only applied definitions for 5 latex symbols. I 
> don't know if there is an upper limit to symbol parameters that can be 
> created in this way. I guess this would be an interesting way to find out 
> ;-)
>
> You then invoke this using the $symbol$ syntax of TW, like:
>
> <<latex """f(x) = $int$_{-$infty$}^$infty$$hat$ f($xi$)\,e^{2 $pi$ i $xi$ 
> x}\,d$xi$"""  >>
>
> This produces:
>
>
>
> Now let's say you want to change the definition of pie on the fly. You can 
> do it like this:
>
>
> <<latex """f(x) = $int$_{-$infty$}^$infty$$hat$ f($xi$)\,e^{2 $pi$ i $xi$ 
> x}\,d$xi$""" pi:"YUM" >>
>
> which produces (I hope these images show up) :
>
>
>
> You can also change the default definition everywhere just by changing the 
> latex macro default parameter for PI.
>
> So, that's my idea. Something to think about.
>
> Mark
>
> On Saturday, July 15, 2017 at 5:44:45 AM UTC-7, Tom wrote:
>>
>> Hi,
>> I'm relatively new to tiddlywiki, but I find it extremely useful and have 
>> moved my research notes to TW. 
>>
>> There is one thing that would make my life much easier: I would like to 
>> define global LaTeX macros, say \elasticity to correspond to \varepsilon, 
>> so that every time I use it in a formula, it would get replace before KaTeX 
>> displays it. Looking at the forums, I see that other people have had a 
>> similar question, but no solution yet. Since it seems that TW has a 
>> built-in macro support, it should not be that difficult to extend it just a 
>> bit. A simple text substitution (whenever I write TW replace it with 
>> tiddlywiki) should do the trick.
>>
>> Just to clarify the importance: in research it is often very useful to 
>> use macros for variable names, because if the notation changes in the later 
>> stages, there is no need to go through everything and change say 
>> \varepsilon to e. It would be also useful to define macros as shortcuts, of 
>> course.
>> Best regards,
>> Tom
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
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/e083afb5-50fb-42db-ba07-3215eb10a7e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to