1

Child document created by lyx is this.

%% LyX 2.3.3 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\begin{document}
Hello
\end{document}

The parent document has this child document.

%% LyX 2.3.3 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{setspace}
\usepackage{babel}
\begin{document}
\begin{onehalfspace}
\input{Hello.tex}.
\end{onehalfspace}
\end{document}

Then, if I convert using pdflatex, I don't get "Hello." I get a redundant blank so I get "Hello ."

How can I fix this?

user1849133
  • 217
  • 2
  • 7
  • Put the dot . in the child document – DG' Nov 01 '20 at 20:31
  • @DG' Thank you. This is good as a partial solution. Is it possible to just fix it more fundamentally? By the way, "Hello" was just an example. I will actually write more words after "Hello" If dot is in the child document, then the next words would have to follow immediate without a blank. – user1849133 Nov 01 '20 at 20:58
  • I don't know if there is anything to fix, because I don't believe it's broken. Your example won't compile, by the way, since Hello.tex contains code, that is only allowed in the preamble. But more importantly: The file contains not only the text, but also an end-of-line character, that means that everything after the input statement starts effectively on a new line. – DG' Nov 01 '20 at 21:06
  • @DG The example will compile in LyX with the original parent file (with .lyx extension). LyX will take care that the child file (Hello.lyx) will be not exported in Hello.tex as a complete document, but only the contents. What the OP has showed in a code preview or the export of Hello.lyx as a stand-alone file, not the real result compiling the parent file. – Fran Nov 01 '20 at 22:20
  • You can try to use \minput, but I don't know, if Lxy will like it. – DG' Nov 01 '20 at 22:37
  • @user1849133 \input{} add only what it is in the .tex file, but in LaTeX the end of lines are spaces. Build a tex file with echo"x" > test.tex and then test what happen with \input{test.tex}. (Note: the extension is not mandatory): The result is x . (with a space). Now make the file with echo"x%" > test.tex and check again. Now the end of line is part of the comment, so is not included as a space. – Fran Nov 01 '20 at 22:38
  • @Fran Thank you but I can't understand. I don't know what echo means. I tested anyways. I converted Hello.lyx to Hello.txt. Then in the parent file, I did input{Hello.tex}. Lyx can't even compile this file – user1849133 Nov 02 '20 at 08:11
  • @user1849133 echo"x" > test.tex is a basic method from the system prompt to make a plain text file that only have the character "x" , but you can use also any plain text editor for that. Your Hello.tex file must have only the word "Hello", not all the code that you posted exporting from lyx directly. Then will always work. Lyx can input lyx files (that are converted in the background to non-stand-alone .tex files) or non-stand-alone .tex files directly, and they will work if there are no wrong code inside, but nest a stand-alone .tex files is completely wrong. – Fran Nov 02 '20 at 08:39

0 Answers0