![在新环境中改变利润](https://linux22.com/image/354837/%E5%9C%A8%E6%96%B0%E7%8E%AF%E5%A2%83%E4%B8%AD%E6%94%B9%E5%8F%98%E5%88%A9%E6%B6%A6.png)
我有一个新的环境定义为
\documentclass[12pt]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{enumitem}
\usepackage{titlesec}
\titleformat*{\section}{\normalsize}
\titlelabel{\bfseries \thetitle.\quad }
\newenvironment{ans}[1][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}
它给出的答案与问题不一致,如下所示。
我想将答案与问题对齐。如何做到这一点?
答案1
嵌套在adjustwidth
环境中,从changepage
可得到解决方案。另一个解决方案是使用ntheorem
来定义\theoremindent
。如果您想要环境结束符号,它可以自动放置它:
\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
\theoremheaderfont{\itshape}
\theorembodyfont{\normalfont}
\theoremseparator{\upshape\ :\ }
\theoremsymbol{\ensuremath{\diamondsuit}}
\newtheorem{varans}{Ans.}
\titleformat*{\section}{\normalsize}
\titlelabel{\bfseries \thetitle.\quad }
\newenvironment{ans}[1][Ans]
{\begin{adjustwidth}{2.05em}{} \hangafter =1\par
{ \itshape #1\ }:\ }{\end{adjustwidth}\medskip}
\title{Title}
\author{SL}
\begin{document}
\maketitle
\section{Prove that a finite subgroup ....}
\begin{ans} Let $F$ be a field and $G $ ... \lipsum[11]
\end{ans}
\lipsum[1]
\section{Prove that a finite subgroup ....}
\begin{varans} Let $F$ be a field and $G $ ... Blah blah blah.
\end{varans}
\lipsum[2]
\end{document}
答案2
你可以简单地用枚举来实现:
\documentclass[12pt]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{enumitem}
\newenvironment{ans}[1][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}
更新:要使用粗体枚举标签,请使用包enumitem
和\setlist[enumerate]{label=\textbf{\arabic*})}
。