in reply to s/[newline]FOO[newline]/\\bar{foo}/sg

perl -p -i.bk -e 's/^ (\w+) $/ \\chapter{$1} /'  *.tex

If there are no spaces before and after the word, remove them from the regex.

qq