This will preserve white space (unlike any solution that assigns to fields) and won't incorrectly match the first 2 letters of "there" when looking for "the" (unlike any solution that doesn't enclose "word" in word delimiters "<...>" or equivalent)
$ gawk 'NR==FNR{list[$0];next}
{
for (word in list)
if ( sub("\\<"word"\\>","\\macro{&}") )
delete list[word]
}
1' list.txt text.txt
The \macro{fish} ate the birds.
The \macro{squirrel} lived in the \macro{tree} on the \macro{mountain}.
The fish did not like eating squirrels as they lived too high in the trees.
The only caveat with this solution is that if "word" contains any RE meta-characters (e.g. *, +) they will be evaluated by the sub(). Since you seem to be using English words that wouldn't happen, but if it can let us know as you need a different solution.
I see you posted that partial matches actually are desirable (e.g. "the" should match the start of "theory") so then you want this:
$ awk 'NR==FNR{list[$0];next}
{
for (word in list)
if ( sub(word,"\\macro{&}") )
delete list[word]
}
1' list.txt text.txt
as long as no RE metacharacters can appear in your matching words from list.txt, or this otherwise:
$ awk 'NR==FNR{list[$0];next}
{
for (word in list)
start = index($0,word)
if ( start > 0 ) {
$0 = substr($0,1,start-1) \
"\\macro{" word "}" \
substr($0,start+length(word))
delete list[word]
}
}
1' list.txt text.txt
That last is the most robust solution as it does a string comparison rather than an RE comparison so is unaffected by RE metacharacters and also will not affect white space (which I know you said you don't care about right now).