I am trying to write a document that has the same question in two places. So, I've written that question down in a seperate tex file, and used the \input command in both places to copy the question.
However, the question has parts (a, b, c) and I would like each part to have its own, seperate tex file. Once I have done so, I used the \input command twice, once for the original quetsion, and the second for the respective part.
Here is the minimal main.tex file used in this project:
\documentclass[12 pt]{book}
%____________________________Packages____________________________________
\usepackage{import} % For large project management
\usepackage[shortlabels]{enumitem} % For enumeration and lists
\usepackage[margin=1 in]{geometry} % Adds 1 inch margins
%___________________________Page Style_______________________________________________
\setlength{\parindent}{0cm} % Removes all indentation
\newcommand{\tab}{\hspace*{1cm}}
% __________________________________Body__________________________________
\begin{document}
\include{Problem_1a}
\end{document}
Here is what Question_1.tex file contains:
\begin{enumerate}
\item[1.]
Some question \#1.
\end{enumerate}
Here is what Question_1a.tex file contains:
\begin{enumerate}
\item[a.]
Some part 1a.
\end{enumerate}
And, finally, here is the code in question, contained in Problem_1a.tex:
\import{./}{Question_1}
% \tab\import{./}{Question_1a}
\tab{}\input{Question_1a}
\textit{Solution.}
\newline
which generates:
However, the '\input' command (also the \import command) seems to create a new line automatically, and even if I put a '\tab' command (that I've written as a macro) it will skip that line and create another.
This is how I want the final result to look like.
But that was only accomplished manually by:
\begin{enumerate}[1.]
\item
Some question \#1.
\begin{enumerate}[a.]
\item
Some part 1a.
\end{enumerate}
\end{enumerate}
How do I force the input command to indent the text it contains (also without creating additional space)?
Note: I don't want to use \input{Question_1a} within Question_1.tex because I want to use Quesiton_1.tex seperatley elswhere within the document.
\import
or\input
introduce only a space afterwards, not a new line. Are there blank lines at the start or end of the file you're inputting/import? Can you post a complete minimal working example, including the definition of\tab
, along with a sample inputted file for it that generates this problem? In general, you should always post code, never screenshots of code.\input
of 1a inside Question_1.tex.instead?\input
or\import
. You'd get the same result if you copied and pasted the results. The enumerate environment starts a new paragraph. You can't indent it that way.\input
for Question_1a.tex inside Question_1.tex (As user202729 suggests) because you sometimes want to use Question_1.tex without including the solution? Rather than trying to emulate an enumerate inside an enumerate with a tab, you could put the\input
for Question_1a.tex in Question_1.tex but inside a boolean conditional.See here. There are also classes specializing in problems and solutions with builtin mechanisms for this like xsim and exercise.