LaTeX \newcommand on Physics Forum post

AI Thread Summary
The discussion centers around using LaTeX on Physics Forums, specifically regarding the creation of custom commands with \newcommand for simplifying expressions in classical field theory. A user successfully defined a command for partial derivatives but sought guidance on uploading .tex files directly to the forum. It was clarified that direct uploads of .tex files are not supported, as the forum utilizes MathJax for LaTeX typesetting, which requires specific syntax. Suggestions included using scripts to convert LaTeX to MathJax-compatible formats and the idea that posting large portions of a document in a single post is discouraged. Additionally, it was noted that LaTeX commands defined in one post remain valid in subsequent posts, allowing for easier reuse of defined commands throughout a thread.
topolosaurus
Messages
2
Reaction score
0
Hello, this is my first question on Physics Forums and is a question on how to ask questions.
I have been using LaTex for a while already.

I wanted to post a thread about classical field theory. I tried to use \newcommand just to make easier the typing of expressions such as:

<br /> \frac{\partial}{\partial \left( \frac{\partial\phi}{\partial x^\mu} \right)}<br />
I haven't been able to do so and I cannot find anything on \newcommand in the main How to Latex on PF guides.

I would like to implement my command as:
Code:
\newcommand{\parcial}[2]{\frac{\partial{#1}}{\partial{#2}}}

Any ideas on how to do that? Probably this has been answered before?
Is there any systematic way of instead uploading a .tex file with all the prompt and packages?
 
Physics news on Phys.org
$$
\newcommand{\dd}[2]{\frac{\partial #1}{\partial #2}}
\dd{f}{x}
$$
Seems to be working to me.
 
Already solved! After some trial and error I managed to put a prompt of redefined commands that seem to be working.
Besides that, is it possible to simply upload .tex files somehow? Because I want to upload part of an article I have been working on and replacing $$ and \begin{equation} to ... is a bit tedious (but not too much though).
 
topolosaurus said:
Besides that, is it possible to simply upload .tex files somehow? Because I want to upload part of an article I have been working on and replacing $$ and \begin{equation} to ... is a bit tedious (but not too much though).
I'm quite sure it is currently not possible to upload ##\LaTeX##-files for verbatim use on the forum, nor when writing an "Insight", for that matter. Both use Mathjax (also see this Insight) which comes with its own set of tags to do the ##\LaTeX##-typesetting.

If you know a language that supports regular expressions (such as Python, or Perl), it is not too hard to write a script that can take a source document and output a text that is ready for pasting into a forum or WordPress post. A while ago I wrote a small script to convert ##\LaTeX##-source into WordPress + QuickLaTeX. It should be easy to adapt to work with Mathjax instead.

However, I would not post large parts of a document on PF, at least not in a single post.
 
  • Like
Likes mfb
why would you want to post the .tex file instead of the produced pdf (let's say)?
 
ChrisVer said:
why would you want to post the .tex file instead of the produced pdf (let's say)?
I don't think he wants to post the .tex file.

I think he wondered whether he could upload a file containing standard ##\LaTeX## (with both text and math) and then have it automatically converted to the MathJax syntax used by the forum. (All text-mode ##\LaTeX## commands - such as ordinary enumerations - should then also be converted into forum-compatible form.)
 
In fact that would be a great feature!
 
It seems that whatever you write in ##\LaTeX## in one set of tags, it is still valid in the others. For example, the previous ##\LaTeX## expression \dd{f}{x} ##\left(\dd{f}{x}\right)## is valid here as it was defined in post #2. But \ddd{f}{x} ##\left(\ddd{f}{x}\right)## is not defined and shows up as an error. It is however defined in this ##hidden\ \LaTeX
\newcommand{\ddd}[2]{\frac{\partial^2 #1}{\partial #2^2}}## (right-click expression and select «Show Math As -> TeX Commands») and now it shows up correctly ##\ddd{f}{x}##.

So just copy your .tex file at the beginning of your first post and it should be valid for your subsequent posts as well. I guess if the thread is spread on multiple pages, the .tex file will have to be rewritten in one early post on each page if needed.
 
  • Like
Likes jim mcnamara, Orodruin, DrClaude and 1 other person
jack action said:
I guess if the thread is spread on multiple pages...
You might be able to just make a reply in the text box of the original page, then select the text, or click select all... then "cut" and paste the text into the reply box on a different numbered page... ?

The below text actually came from another thread...
Noisy Rhysling said:
A safer saw has my approval.
Here's a screen shot of what I'm trying to say...

Cut and Paste.JPG


Clear as mud, eh ? :oldsmile:
 
Last edited:

Similar threads

Replies
5
Views
3K
Replies
6
Views
3K
Replies
23
Views
2K
Replies
39
Views
7K
Replies
3
Views
1K
Back
Top