I am trying to write a macro to input a set of small text files into a larger file, in lualatex, but seeing some variances how the text is inserted in the main file.
So far I prepared this:
\documentclass[11pt]{report}
\usepackage{amsthm}
\usepackage{polyglossia}
\setmainfont{STIX Two Text}
\usepackage[
a4paper,
margin=4cm,
marginparwidth=50pt,
]{geometry}
\newtheoremstyle{problemstyle}% name of the style to be used
{\topsep}% measure of space to leave above the theorem. E.g.: 3pt
{\topsep}% measure of space to leave below the theorem. E.g.: 3pt
{}% name of font to use in the body of the theorem
{0pt}% measure of space to indent
{\bfseries}% name of head font
{}% punctuation between head and body
{ }% space after theorem head; " " = normal interword space
{\thmname{#1}\thmnumber{ #2}\textbf{\thmnote{ (#3)}}}
\theoremstyle{problemstyle}
\newtheorem{problema}{\textbf{Problem}}[section]
\newcommand{\bp}[1]{\begin{problema}[#1] \input{#1} \label{#1}\end{problema}}
\begin{document}
\bp{Fa87}%
\begin{problema}[Fa87]
Prove that $\cos^p \theta \leq \cos p\theta$ for
$0 \leq \theta \leq \pi /2$ and $0 < p < 1$.
\end{problema}
\begin{problema}[Fa87]
Prove that $\cos^p \theta \leq \cos p\theta$ for
$0 \leq \theta \leq \pi /2$ and $0 < p < 1$.
\end{problema}
\begin{problema}[Fa87]
Prove that $\cos^p \theta \leq \cos p\theta$ for
$0 \leq \theta \leq \pi /2$ and $0 < p < 1$.
\end{problema}
\end{document}
ẁith the text of Fa87 to be exactly
Prove that $\cos^p \theta \leq \cos p\theta$ for
$0 \leq \theta \leq \pi /2$ and $0 < p < 1$.
all of it to be processed with lualatex. The variance can be seen here:
where the spacing after the entry that uses the command \bp is about twice as much as the spacing of all others, entered directly into the text.
Observe that the text introduced by the command is exactly the same as the one directly in the main file.
The problem seems to be related to the text getting closer to the end of the line, but I fail to gresp how to address it.






! Missing \endcsname inserted. <to be read again> relax l.31 \bp{Fa87} %polyglossiapackage without a language choice doesn't do much good. I guess you're loadingpolyglossiafor its side-effect of sorts, which is to load thefontspecpackage, thereby enabling the use of\setmainfont.. For coding clarity, I think it would be useful to replace\usepackage{polyglossia}with\usepackage{fontspec}or -- better yet --\usepackage{unicode-math}since (a)unicode-mathalso loadsfontspecautomatically and (b)unicode-mathenables the use of\setmathfont.