1

I am currently making a document with this environment.

I would like to have a tabbed over section of text, which I am doing with \adjustwidth. I would like to have another tabbed over section within this section without whitespace above and below. How can I do this?

I realize that I did not use the ebook layout for the MWE. I didn't want to put all of the extra stuff included in ebook. I apologize.

MWE:

\documentclass{article}

\usepackage{changepage} % for use of a tabbed over section for a small portion of the text e.g. in chapter 1

\begin{document}

\begin{adjustwidth}{2.5em}{0pt} I want these words at this level \ More at this level \ \begin{adjustwidth}{2.5em}{0pt} I want these words at this level \ I do not want the whitespace above and below this level \ \end{adjustwidth} How can I get rid of the whitespace above and below the nested adjustwidth, or what's the best way to do this?\ \end{adjustwidth}

\end{document}

enter image description here

K. Shores
  • 265

1 Answers1

1

You can adjust the paragraph shape based on the specific number of lines:

enter image description here

\documentclass{article}

\usepackage{changepage}

% http://tex.stackexchange.com/a/133660/5764
\makeatletter
\def\newparshape{\parshape\@npshape0{}}
\def\@npshape#1#2#3{\ifx\\#3\expandafter\@@@npshape\else\expandafter\@@npshape\fi
{#1}{#2}{#3}}
\def\@@npshape#1#2#3#4#5{%
\ifnum#3>\z@\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
{\expandafter\@@npshape\expandafter{\the\numexpr#1+1\relax}{#2 #4 #5}{\numexpr#3-1\relax}{#4}{#5}}%
{\@npshape{#1}{#2}}}
\def\@@@npshape#1#2#3{#1 #2 }
\makeatother

\begin{document}

\begin{adjustwidth}{2.5em}{0pt}
I want these words at this level \\ 
More at this level \\ 
\begin{adjustwidth}{2.5em}{0pt}
  I want these words at this level \\ 
  I do not want the whitespace above and below this level \\ 
\end{adjustwidth}
How can I get rid of the whitespace above and below the nested adjustwidth, or what's the best way to do this?\\ 
\end{adjustwidth}

\newparshape{2}{2.5em}{\dimexpr\linewidth-2em}{2}{5em}{\dimexpr\linewidth-5em}{1}{2.5em}{\dimexpr\linewidth-2.5em}\\
\noindent I want these words at this level \\ 
More at this level \\ 
  I want these words at this level \\ 
  I do not want the whitespace above and below this level \\ 
How can I get rid of the whitespace above and below the nested adjustwidth, or what's the best way to do this?\\ 

\end{document}
Werner
  • 603,163