0

I would like to include a number of subfiles, each of which contains a single sentence, so that together they form a paragraph. However, the subfiles package makes each sentence into a separate paragraph, with a linebreak. Is there any way to edit the subfiles package so that when you include a subfile, it doesn't add a linebreak?

Rough example:

\begin{document}
\subfile{s1}\subfile{s2}\subfile{s3}
\end{document}

s1:

\documentclass[../main]{subfiles}
\begin{document}
This is my sentence.
\end{document}

Etc.

julkarham
  • 299

1 Answers1

1

The layout seems to be caused by line breaks in the subfile. Given the following MWE the output does not contain any extra space or linebreaks:

subfmain.tex

\documentclass{article}
\usepackage{subfiles}
\begin{document}
\subfile{s1}\subfile{s1}\subfile{s1}
\end{document}

s1.tex:

\documentclass[subfmain]{subfiles}\begin{document}This is my sentence.\end{document}

Make sure there is also no additional line break at the end of the subfile, i.e., an empty line after \end{document}.

Result:

enter image description here

Marijn
  • 37,699
  • Thank you, that works – julkarham Aug 25 '19 at 17:47
  • Is there a way to fix the actual package so that if there are no newlines between \begin{document}, the text, and \end{document} then there won't be any in the output? – julkarham Sep 16 '19 at 14:40
  • Do you mean that newlines before \begin{document} and after \end{document} should be stripped? I don't think that this would be easy - however, for simple files like this it might be easier to just use \input{subfile} and not use the subfiles package at all. – Marijn Sep 17 '19 at 05:26