I'm looking for a way to find and replace a string throughout a tex file by adding a line of code, without doing any type of manual "find and replace." The reason is that I'm using tex fragments that are the output of a Stata regression, and I have one main Stata file where I insert all the tex fragments, using the \input command. However, I want to change parts of the tex code without actually opening up those files. For example, I want to change the variable name to a latex construction, so that it appears properly in my tables. Here is the code from the main .tex file:
Code: Select all
\documentclass[10pt]{article}
\usepackage[margin=1in]{geometry}
\begin{document}
\input{wagesinc}
\input{hours}
\input{parttime2}
\input{parttimelw}
\end{document}
\beta
by inserting an additional line of code into the main .tex file here.I know that, for example, the PSfrag package allows one to replace tags in an .eps file with Latex constructions. I essentially want to do what I think is a simpler task: replace the strings directly in the .tex code.
I also know that the xstring package allows one to substitute in a string, so if I knew how to refer to the entire fragment of tex code as a string, that may help. However, I tried using the xstring package and the following line:
Code: Select all
\StrSubstitute{\input{hours}}{beta}{\beta}
So knowing either a function to search a file and output the file with all the substitutions, or knowing how to bring in the .tex fragment all as a string to search so that I can use the StrSubstitute function would be helpful.
Thanks!