# What I want

I have a document that includes text from several external .tex files. These files can contain \section{} commands or \begin{quote} environments. Furthermore, I use the lineno package to number the lines of the includes files. To allow writing notes to the printing documents, I would like to limit the width of the included text. This width, however, should only affect the included text and not other parts of the document.

## Code example

Basically, my code should look like this:

\chapter{Entry number 10}
Text text text text text text text text text text text text text

% HELP ME: command to set text width

\linenumbers
\input{external.tex}
\nolinenumbers

% HELP ME: command to reset text width


## How the result should look like

ENTRY NUMBER 10
===============

Text text text text text text text text text text text text text

1. Included part 10-a
---------------------

2. Text of the included part that has
3. a smaller text width that even works
4. when quotations or other subsections
5. are used.

6. Note the line numbers.


# Minimal Example

Here is an example to demonstrate what I want and what does not work:

\documentclass{article}
\usepackage{lineno}
\usepackage{lipsum}

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% imagine this part is included from a file %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% show line numbers
\linenumbers

% HELPME: something that does not correctly work
\par\begingroup\rightskip12em

% a paragraph with correct margin
\section{This is an example for a very long subtitle}
\lipsum[1]

% margin is ignored for quoted text
\begin{quote}
\lipsum[1]
\end{quote}

% margin is ignored for item lists
\begin{itemize}
\item \lipsum[1]
\end{itemize}

\par\endgroup

% no line numbers beyond this
\nolinenumbers
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}


Note that text in the quote environment and the list does not have a correct margin.

# What I tried

• minipage: Works perfectly, but does not work if the included document is longer than one page. A minipage environment that floats over many pages would help
• \newgeometry{} command of the geometry package: Works perfectly, but always begins a whole new page. I, however, want the change to only affect the included part and not the surrounding text.
• Using adjustwidth environment from the changepage package: This does not work when the text in the environment contains \section{} commands.
• Using an environment and change its width: Had several issues... For instance, the margin was ignored as soon as the included text contained a quote. Other environment could not cope with \section{} commands in the included text.

# Another problem

\documentclass{report}

\usepackage{changepage}

\begin{document}

\chapter{Text1}

\section{Text2}

Text3

\begin{quote}
Text4
\end{quote}

\end{document}


The reason why I did not use adjustwidth before was that the above example has a compilation error: "Something's wrong--perhaps a missing \item." in the line of \begin{quote}. The error disappears when I remove either of

• the line \chapter{Text1}
• the line \section{Text2}
• the line Text3
• the adjustwidth environment

How can this be?

Edit: I asked a new question (Strange compilation problem using adjustwidth environment from changepage package) and close this one.

-
possible duplicate of Write text with some fixed amount of space from the margin –  Marco Daniel Jun 23 '12 at 9:13
Unfortunately not: The adjustwidth environment does not seem to work if commands like \section are used. –  Niels Lohmann Jun 23 '12 at 11:38
Please add a minimal working example (MWE) that illustrates your problem. –  Marco Daniel Jun 23 '12 at 11:40
I added an example. I hope this demonstrates what I want. –  Niels Lohmann Jun 23 '12 at 12:01
I put the compilation error into a new question: tex.stackexchange.com/questions/60992/… –  Niels Lohmann Jun 23 '12 at 23:24

\documentclass{article}
\usepackage{lineno}
\usepackage{lipsum}
\usepackage{showframe}
\usepackage{changepage}
\begin{document}
\linenumbers
\section{This is an example for a very long subtitle}
\lipsum[1]
\begin{quote}
\lipsum[1]
\end{quote}
\begin{itemize}
\item \lipsum[1]
\end{itemize}

I explained the problem arising with adjustwidth above under "Another problem". It brings me a strange compilation error. –  Niels Lohmann Jun 23 '12 at 12:49