Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

LaTeX \newcommand on Physics Forum post

  1. Aug 4, 2017 #1
    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):
    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. jcsd
  3. Aug 4, 2017 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Gold Member
    2017 Award

    \newcommand{\dd}[2]{\frac{\partial #1}{\partial #2}}
    Seems to be working to me.
  4. Aug 4, 2017 #3
    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 [tex] ... [/tex] is a bit tedious (but not too much though).
  5. Aug 5, 2017 #4


    User Avatar
    Science Advisor
    Education Advisor

    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.
  6. Aug 6, 2017 #5


    User Avatar
    Gold Member

    why would you want to post the .tex file instead of the produced pdf (let's say)?
  7. Aug 6, 2017 #6


    User Avatar
    Science Advisor
    Education Advisor

    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.)
  8. Aug 17, 2017 #7


    User Avatar
    Science Advisor
    Gold Member
    2017 Award

    In fact that would be a great feature!
  9. Aug 17, 2017 #8

    jack action

    User Avatar
    Science Advisor
    Gold Member

    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.
  10. Aug 17, 2017 #9


    User Avatar

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

    Cut and Paste.JPG

    Clear as mud, eh ? :oldsmile:
    Last edited: Aug 17, 2017
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted