I'm having issues with text going past the end of the specified \textwidth. I posted this question about why text was being placed beyond the specified line width. The MWE provided there produced situations similar to mine. Adding \sloppy fixed all the problems posted in that MWE, but when I used that in my larger document, it had absolutely no effect on the output.
Narrowing my problem down further, I see that the problem stems from the \iteminput macro which is a solution provided to an issue related to the alignment of item number in a list containing a minipage that was originating in a standalone file. I have been using this to input my files. This macro was necessitated by the fact that the imported standlalone files were not being aligned within enumerated lists.
It appears that \iteminput is ignoring that fact that the \linewidth has modified since it is now within an enumerate list. So, my question is: How do I adjust the \iteminput macro to respect the current \linewidth.
The MWE for this requires two files. The first file here is the standalone file called Item-from-File.tex:
\documentclass[preview=false]{standalone}
\usepackage{standalone}
\usepackage{paralist}
% geometry settings identical to main file.
\usepackage{geometry}
\geometry{top=0.5in}
\geometry{bottom=0.5in}
\geometry{paperheight=11.0in}
\geometry{paperwidth=8.5in}
\geometry{textwidth=6.0in}
\geometry{left=1.125in}
\geometry{right=1.125in}
\geometry{showframe=true}
\begin{document}
Here is a line of text, but one that is from a separate standalone file.
This file typeset by itself is fine. When this is input into an enumerated list
via the normal input macro, things are also fine. But the text goes past the end
of the line if input with modified input macros.
%
% Updated to include following:
\begin{enumerate}[(a)]
\item First item: If this sentence is long enough things are not so good when
this is included in another file. But things are fine in this standalone
file.
\begin{enumerate}[(i)]
\item First sub-item: If this sentence is long enough things are not so good
when this included in another file. But things are fine in this
standalone file.
\end{enumerate}
\end{enumerate}
\end{document}
The second is the main document:
\documentclass{article}
\usepackage{standalone} % Needed for the standalone file
\usepackage{paralist}
% geometry settings identical to standalone file.
\usepackage{geometry}
\geometry{top=0.5in}
\geometry{bottom=0.5in}
\geometry{paperheight=11.0in}
\geometry{paperwidth=8.5in}
\geometry{textwidth=6.0in}
\geometry{left=1.125in}
\geometry{right=1.125in}
\geometry{showframe=true}
\newcommand{\iteminput}[2][\topskip-1bp]{%
\leavevmode\vtop{\hrule height 0pt\kern-\dimexpr#1\relax
\input{#2}}}
\begin{document}
Text in this file, things work great:
\begin{enumerate}
\item When this text appears in the same file things are ok.
The line goes to the end of the correct spot on the page and wraps around.
\item \input{Item-from-File.tex}% This is ok
\item \iteminput[2.5ex]{Item-from-File.tex}% This is a problem
\end{enumerate}
\end{document}
\iteminputline. – egreg May 17 '11 at 06:49\inputand it seems to work fine: – Peter Grill May 17 '11 at 07:23paralistwas requried for theenumerateenvironment? It is needed in both files. I posted a related question: what are the differences between using paralist vs enumitem – Peter Grill May 17 '11 at 07:47\vtophere is not going to interact well with the rest of the galley. Perhaps you should update this answer to useminipageas he mentions. – Bruno Le Floch Jul 29 '12 at 12:16