Here is a MWE. Actually I am using latex2html for a web page. LaTeX works using \protect, but not latex2html.







1 <

<3>>Title Sample Sample text.

  • "LaTeX complains": what error or warning are you getting exactly? Is it "Argument of \@sect has an extra }." ? I get this when compiling your MWE. This is due to the argument of \section being a moving argument and can be solved by protecting the command \input, like this: \section{\protect\input{titles/title-sample}}.
    – marquinho
    Commented Nov 14, 2021 at 13:15
  • You are right. \protect works with LaTeX. But with latex2html, I receive a "? brace missing for \section" warning, and HTML output like:1 < <3>>Title Sample Sample text.
    – russ
    Commented Nov 14, 2021 at 14:17
  • You could define the titles as macros in the preamble. or even put all of them into one file. In CPU years, IO takes forever. Commented Nov 14, 2021 at 15:11
  • Please give me a bit more detail. Titles presently number about 150; maximum number is about 350. The website is not going to be updated more than about once a day, so run time is not an issue.
    – russ
    Commented Nov 14, 2021 at 15:30
  • I have no problem using htlatex rather than latex2html. The usage of catchfile as proposed in the now deleted answer is better, as it avoids spurious spaces. Note that TeX4ht is actively maintained, which latex2html seems not to be.
    – egreg
    Commented Nov 14, 2021 at 15:49


You must log in to answer this question.

Browse other questions tagged .