# LaTeX \newcommand on Physics Forum post

Tags:
1. Aug 4, 2017

### topolosaurus

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:

$$\frac{\partial}{\partial \left( \frac{\partial\phi}{\partial x^\mu} \right)}$$
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 (Text):
\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?

2. Aug 4, 2017

### Orodruin

Staff Emeritus
$$\newcommand{\dd}[2]{\frac{\partial #1}{\partial #2}} \dd{f}{x}$$
Seems to be working to me.

3. Aug 4, 2017

### topolosaurus

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 to $$...$$ is a bit tedious (but not too much though).

4. Aug 5, 2017

### Krylov

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.

5. Aug 6, 2017

### ChrisVer

why would you want to post the .tex file instead of the produced pdf (let's say)?

6. Aug 6, 2017

### Krylov

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.)

7. Aug 17, 2017

### vanhees71

In fact that would be a great feature!

8. Aug 17, 2017

### jack action

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.

9. Aug 17, 2017

### OCR

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...
Here's a screen shot of what I'm trying to say...

Clear as mud, eh ?

Last edited: Aug 17, 2017