0

--Edit-- (rewrite the code that I use currently to produce margin left)

This is code that I try to make a new environment (leftwhitespace) of, instead of writing these code that create list with 1 item:

\begin{itemize} 
    \item[]
      line 1
      line 2
\end{itemize}

Want to create new environment leftwhitespace that will do as code above (add margin left):

\begin{leftwhitespace}
    line 1
    line 2
\end{leftwhitespace}
6
  • I want create custom environment vs each time add \hangindent=1em or leftmargin=3cm etc... vs suggested in tex.stackexchange.com/a/56813/197451. (Compare to html and css I want create class that can be included each time that I want instead write inline css.) – Ben Nov 24 '19 at 10:48
  • something like this-------- tex.stackexchange.com/questions/51548/… – js bibra Nov 24 '19 at 11:44
  • the link above for more complete cases, I just need to add \hangindent=1em for the paragraph and this custom paragraph. (Soo I try create newenvironment, but the code that I put not works, I need to correct my code inside newenvironment) – Ben Nov 24 '19 at 12:13
  • please place the complete code above for a valuable reply starting with \documentclass and finishing with \end{document} – js bibra Nov 24 '19 at 12:20
3

If I understand well what you want, changepage already has an environment for that:

\documentclass{article}
\usepackage{lipsum}
\usepackage{changepage}

\begin{document}

\lipsum[10]
\begin{adjustwidth}{3em}{0pt}
\lipsum[11-12]
\end{adjustwidth}

\lipsum[13]

\end{document} 

enter image description here

4
  • ok, but how can be that code put inside newenvironment (I want to have default left margin) – Ben Nov 24 '19 at 22:22
  • You should explain what you want to do exactly. This environment does not change the default lefty margin. It only changes the left margin inside itself. – Bernard Nov 24 '19 at 22:25
  • Hi, thanks for solution, how can I create custom environment for solution that you suggested: you suggested: \begin{adjustwidth}{3em}{0pt} \lipsum[11-12] \end{adjustwidth} -> (I want to write that) \begin{custom_adjustwidth} \lipsum[11-12] \end{custom_adjustwidth} (without each time write: {3em}{0pt}, I want to write {3em}{0pt} inside custom environment definition) – Ben Nov 29 '19 at 1:15
  • You can add something like this to your preamble: \newenvironment{myenvt}{\adjustwidth{3em}{0pt}}{\endadjustwidth} and use it as \begin{myenvt} ... \end{myenvt} – Bernard Nov 29 '19 at 9:48
2

Does this solve your query:

enter image description here

enter image description here

enter image description here

\documentclass{article}
\usepackage{lipsum}

\newenvironment{hanglist}[1][\parindent]{%
    \begin{list}{}{%
        \setlength{\leftmargin}{#1}
        \setlength{\labelwidth}{0pt}
        \setlength{\labelsep}{0pt}
        \setlength{\itemindent}{-#1}}
    }{%
        \end{list}
    }

\def\D{\par\noindent\makebox[1em][l]{-- }\hangindent1em}

\newcommand{\detail}[1]{\par\noindent\hangindent=\mylen\hangafter1-- #1}
\newlength{\mylen}
\settowidth{\mylen}{-- }
\begin{document}
\begin{hanglist}[2cm]
\item\lipsum[1]
\item\lipsum[2]
\end{hanglist}

    Regular itemize
    \begin{hanglist}[1cm]
       \item First
       \item Second 
       \item Third
    \end{hanglist}

\subsubsection*{This is a header}
\D This is a detail
\D This is a detail that has too many words in it and consequently runs onto The next line of the page, and I want it to have a hanging indent.

\noindent\textbf{This is a header}
    \detail{This is a detail.}
    \detail{This is a detail that has too many words in it and consequently runs onto the next line of the page, and I want it to have a hanging indent.}
\end{document}
1
  • thanks! can you please see edit that I made? – Ben Nov 24 '19 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.