# change margin in newenvironment

1,379

## Solution 1

Nesting in an adjustwidth environment, from changepage leads to a solution. Another solution consists in using ntheorem to define a \theoremindent. If you want an end-of-environment symbol, it can place it automatically:

\documentclass[12pt]{article}

\usepackage[margin=0.5in]{geometry}
\usepackage{amsmath, amssymb}
\usepackage{enumitem}
\usepackage{titlesec, changepage, lipsum}

\usepackage[thmmarks, amsmath]{ntheorem}
\theoremstyle{nonumberplain}
\theoremindent = 2.05em
\theorembodyfont{\normalfont}
\theoremseparator{\upshape\ :\ }
\theoremsymbol{\ensuremath{\diamondsuit}}
\newtheorem{varans}{Ans.}

\titleformat*{\section}{\normalsize}

\newenvironment{ans}[Ans]

\title{Title}
\author{SL}

\begin{document}

\maketitle
\section{Prove that a finite subgroup ....}
\begin{ans} Let $F$ be a field and $G$ ... \lipsum
\end{ans}

\lipsum
\section{Prove that a finite subgroup ....}
\begin{varans} Let $F$ be a field and $G$ ... Blah blah blah.
\end{varans}

\lipsum

\end{document} ## Solution 2

You could simply do it with an enumeration: \documentclass[12pt]{article}

\usepackage[margin=0.5in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{enumitem}

\newenvironment{ans}[Ans]
{
\\ { \it #1\ }:\
}

\begin{document}
\title{Title}
\author{SL}
\maketitle
\begin{enumerate}
\item Prove that a finite subgroup ....
\begin{ans}
Let $F$ be a field and $G$ ...
\end{ans}
\end{enumerate}
\end{document}


Update: To have bold enumeration labels use package enumitem and \setlist[enumerate]{label=\textbf{\arabic*})}.

Share:
1,379 Author by

Updated on May 15, 2020

• I have a new environment defined as

\documentclass[12pt]{article}

\usepackage[margin=0.5in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{enumitem}
\usepackage{titlesec}

\titleformat*{\section}{\normalsize}

\newenvironment{ans}[Ans]
{
{ \it #1\ }:\
}

\begin{document}
\title{Title}
\author{SL}
\maketitle
\section{Prove that a finite subgroup ....}
\begin{ans} Let $F$ be a field and \$G ...
\end{ans}
\end{document}


It produces answer that does not align with the question as follows. I would like to align the answer to the question. How do it do it?

• TeXnician over 6 years
Why do you use sections for that? Would it be okay for you to use enumeration?
• • • I believe the fully correct syntax would be to use the lower level pair \adjustwidth … \endadjustwidth, but here the highest level works. Note the alignment will be problematic if the section numbers have more than one digit (unless you put the section numbers in the margin, with the advanced interface of titlesec).