But, for some purpose, I want my tex file in the format with the replaced commands; i.e. tex code that I would have written had I not known about \newcommand at all.
Is there some way to obtain this processed tex code?
I must confess I do not understand at all what you want? Do you want to automatically replace all appearances of \ket{bla} in your source with \left|bla\right>? I guess it's possible to right a shell script for this but that is not my field of expertise (meaning I have never done that myself).
BTW: there's the braket package for, well, bras, kets and brakets.
Yes, that is what I have in mind: I want to automatically replace all appearances of \ket{bla} in your source with \left|bla\right>. Is there a way to do this?
ps: Thanks for the information about the braket package.
Last edited by cgnieder on Tue Sep 04, 2012 9:47 pm, edited 1 time in total.
That's not a LaTeX topic, it's just text replacement. You can do it by using editor features, by processing the file by sed, perl, ... LaTeX doesn't manipulate your source file. It does macro processing and expansion naturally, so I think normally it's not needed with LaTeX to process the source file for replacement before compiling.
I want to automatically replace all appearances of <my input to new-command eg.\ket{bla}> in your source with <the replaced code (as a result of newcommand) eg.\left|bla\right>)
Yes.
It would be great if I can somehow get the 'final' source file, in which all the occurrences of the old commands are replaced as I have described in the newcommand. Is there an easy way to do this?
Sounds like a simple string replacement, which could be done with sed and other tools. But in consequence any contained macro should be expanded and replaces as well.
Since LaTeX does exactly that automatically during the compilation, why do you want to modify the source? Isn't the expansion for the output sufficient? Is there a specific reason? Is \newcommand not allowed for you? LaTeX is a macro language based on macro defitions. Forbidding that is strange.
I and my friends have lengthy (lecture and reading)notes which make extensive use of newcommand. I wanted to convert those docs to wordpress to make them public and collaborative. We found a tool (http://lucatrevisan.wordpress.com/latex-to-wordpress/) that converts latex to wordpress code, but as an input to this tool, I need the replaced version of out tex source. I understand that latex does just this same replacement during complication and was, hence, wondering if there was some way to obtain the 'intermediate (partly compiled) code'.