Personalized latex macros: hard or easy?

  • Context: LaTeX 
  • Thread starter Thread starter strangerep
  • Start date Start date
  • Tags Tags
    Hard Latex
Click For Summary

Discussion Overview

The discussion revolves around the feasibility and implications of implementing personalized LaTeX macros for users in a forum setting, particularly in the context of mathematical expressions and notation commonly used in quantum mechanics. Participants explore the potential benefits, challenges, and technical requirements of such a feature.

Discussion Character

  • Debate/contested
  • Technical explanation
  • Exploratory

Main Points Raised

  • Some participants express a desire for predefined macros to simplify the typing of complex LaTeX expressions, particularly for bra-ket notation.
  • Others argue that implementing macros would require significant changes to the forum's underlying code, particularly with respect to the vBulletin platform and its integration with MathJax.
  • A participant notes that macros in signatures may not be effective since not all users utilize signatures, and quoting posts would not include these macros.
  • One participant suggests that expanding macros before storing posts could allow quoted text to display standard LaTeX, but raises concerns about the difficulty of editing posts if macros are expanded.
  • Another participant proposes a system where users could define their own macro files, which could be referenced by others, potentially resolving issues with quoting and accessibility of macros.
  • Concerns are raised about the implications of personalized macros on the visibility and functionality of quoted posts, as well as the potential need for dual storage of posts to accommodate both original and expanded macro versions.

Areas of Agreement / Disagreement

Participants generally do not reach a consensus on the implementation of personalized macros, with multiple competing views on the technical feasibility and practical implications remaining unresolved.

Contextual Notes

Limitations include the dependence on the forum's existing software architecture, the potential complexity of managing user-defined macros, and the challenges associated with quoting and editing posts that utilize these macros.

strangerep
Science Advisor
Messages
3,766
Reaction score
2,214
When I'm typing latex math (with frequent bras and kets) in the quantum forum, I often put this first:

\def\<\rangle
\def\>\langle

because this is annoyingly ugly: ##<\psi | \phi>,~##
but this: ##\langle\psi | \phi\rangle##
is a pain to type and edit if there's a lot of it.

(There's a few other things, such as abbreviations for oft-used math characters in particular fonts).

So,... umm,... I was just wondering... is it be hard or easy to implement a (modest-sized) set of predefined macros on a per-user basis?
 
Physics news on Phys.org
It might work to put macros in the signature*. But not all users have signatures. And a bigger problem is that if someone tries to quote something you did on an earlier page or in a different thread, the macros won't be included.

I would guess that the vBulletin developers would have to make a lot of changes to the code to make something like this work smoothly.

*) I tried to test this theory with this post, but I couldn't get any kind of signature to appear.


Note by the way that the | in your bra-ket is too short. Kets can get even uglier when we use other symbols. Example: ##|\uparrow\rangle##. This should probably be typed as \left|\uparrow\right\rangle. ##\left|\uparrow\right\rangle##. The best code I can think of for your bra-ket is this:
Code:
\left\langle\psi\left|\,\phi\right. \right\rangle
Result: $$\left\langle\psi\left|\,\phi\right. \right\rangle$$ But I don't even that is perfect, because the size of the | will now be determined only by the ##\phi##.
 
Last edited:
Fredrik said:
*) I tried to test this theory with this post, but I couldn't get any kind of signature to appear.
You need a signature first, before posts can be configured (!) to show this signature. If you do not have one, all new posts are created with the default setting "do not show signature".

This forum uses MathJax to show formulas, which has nothing to do with vBulletin - and the vBulletin for LaTeX code ignore the author. I doubt that default macros would work without significant coding effort.
 
mfb said:
You need a signature first, before posts can be configured (!) to show this signature. If you do not have one, all new posts are created with the default setting "do not show signature".
Ah, you're right. The problem must have been that I created the post and started editing before I created the signature. I had no problem getting a signature to appear when I tried it a minute ago. I tried one with a LaTeX \newcommand. I put the new command in the post, but it wasn't understood by MathJax when I previewed.

mfb said:
This forum uses MathJax to show formulas, which has nothing to do with vBulletin - and the vBulletin for LaTeX code ignore the author. I doubt that default macros would work without significant coding effort.
OK, that makes sense.
 
I used to define a macro like

\newcommand\braket[2]{\ensuremath\left\langle #1\vphantom{#2} \mid #2\vphantom{#1} \right\rangle

especially for this. Problem is then you also need a one and three argument variant for [itex]\langle\phi\rangle[/itex] and [itex]\langle \phi \mid \hat A \mid \psi \rangle[/itex] of course.
 
I have made a mental note of that vphantom trick. I may have to use it in the future. Thanks.
 
Suppose this were possible. I think you'd have a huge issue dealing with quoted posts.

For example, I have probably 100 macros I'd like to define. Things like

\newcommand{\cR}{\mathcal{R}}

for calligraphy letters, and

\DeclareMathOperator{\into}{\raisebox{0.2ex}{\reflectbox{\rotatebox[origin=c]{180}{$\neg$}}}}

for the interior product. I would show you, but it looks like MathJax can't interpret that one correctly.

Anyway, if I type up a post using a bunch of my macros, and then someone quotes it, what code should be displayed in their editing box? If macros are personalized, then they won't have access to my macros. So if my macros are used in their post, they won't work.

OK, but suppose we have the interpreter process my quoted text using my macros. Fine, but the person quoting me might remove my username. Or might try to use one of my macros himself (one way people learn Latex is by quoting one another on here).

OK, so maybe instead of showing him my code as written, it could be pre-processed to expand all macros before it is stored in the database. Then when someone quotes it, it just shows them standard Latex. They can see exactly how everything is done, the software doesn't have to remember who originally posted everything, and they can copy and paste things into their own post, and it will work fine.

Great, but now what if I need to edit one of my own posts? If all my macros get expanded before saving to the database, this will get very tedious. It looks like the only solution is to store 2 copies of every Latex-enabled post, and that is surely not a good solution, as I'm sure PF's storage requirements are already substantial (which is, in fact, why they switched to MathJax instead of their previous method).
 
Ben Niehoff said:
Anyway, if I type up a post using a bunch of my macros, and then someone quotes it, what code should be displayed in their editing box? If macros are personalized, then they won't have access to my macros. So if my macros are used in their post, they won't work.
That lead me to an interesting idea. Those macros could be used similar to Wikipedia .css changes: Every user can define his own, but other users can refer to that as well.

As an example, you create "benniehoff.tex" which is stored somewhere on the server (probably in a database and not as a file). Afterwards, it could be included like $$<benniehoff.tex> 1+2$[/color]$, where the board replaces <benniehoff.tex> by your macros. Quotes are no problem, and you don't have to re-invent the wheel every time.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K
  • Sticky
  • · Replies 2 ·
Replies
2
Views
506K