For my homework questions, I have multiple questions which present proof-type and standard solution-type answers. So as something similar to the standard amsthm \begin{proof}....\end{proof} environment, I have defined a new environment within my Macro package for a solution environment as follows:
\newenvironment{soln}{%
\noindent\par\textbf{Solution:}}{\par\medskip
}
However, I noticed that when I had included a figure within the standard amsthm proof environment, the figures would align and indent correctly within the environment, so that a figure caption for example would center within the environment and not just within the document. An example of this is here:
This screenshot was produced with the following code:
\begin{proof}
The required vector plot is as follows,
\begin{figure}[H]
\caption{Plot of vectors at each of the points (see Legend for details)}
\centering
\includegraphics[scale=0.25]{5a.jpeg}
\end{figure}
\end{proof}
However, within my new solution environment with the following code:
\begin{soln}
\begin{figure}[H]
\caption{Plot of the slope field and solution curves for $(1, 1)$ and $(1.25, 1.25)$}
\centering
\includegraphics[scale=0.25]{5c.png}
\end{figure}
\end{soln}
I get the following screenshot instead:
The problem here is that the figure hasn't aligned with the word 'Solution' in the same way that it aligns with the word 'Proof' in the amsthm environment. I'm wondering what I can do to fix this, if it's a problem with the way I've set out my code for figures or if it's a problem with the way my environment works. I'm still pretty new to latex and working out how the spacing and margins works, so a bit of an explanation would be really helpful to me (as well as a solution). Thanks in advance!
Edit: It is worth noting that this error occurs inside an itemize
environment and the document class is \documentclass[12pt]{article}
and the following settings in my preamble \parindent = 0mm
, \parskip = 2mm
, \pagestyle{empty}
if potentially that's messing with the indenting.
Edit 2: Here is a proper worked example to demonstrate the issue:
\documentclass[12pt]{article}
\usepackage{amsthm, amssymb, amsmath, enumerate, mathtools, enumitem}
\usepackage{graphicx}
\usepackage{float}
\graphicspath{{./Images/}}
\newenvironment{soln}{%
\par\noindent\textbf{Solution:}}{\par\medskip
}
\setlength{\textwidth}{168.0truemm}
\setlength{\textheight}{265.0truemm}
\setlength{\oddsidemargin}{-4.0mm}
\setlength{\evensidemargin}{-4.0mm}
\setlength{\topmargin}{-22.0truemm}
\parindent=0mm
\parskip=2mm
%%%\parskip=1.5mm
\pagestyle{empty}
\begin{document}
\begin{itemize}
\item[{\bf 1}]
\begin{itemize}
\item[a)] This is the first figure:
\begin{proof}
Here is where I put my first figure
\begin{figure}[H]
\caption{Plot of vectors at each of the points (see Legend for details)}
\centering
\includegraphics[scale=0.25]{5a.jpeg}
\end{figure}
\end{proof}
\newpage
\item[b)] This is the second figure:
\begin{soln}
Here is where I put my second figure:
\begin{figure}[H]
\caption{Plot of the slope field and solution curves for $(1, 1)$ and $(1.25, 1.25)$}
\centering
\includegraphics[scale=0.25]{5c.png}
\end{figure}
\end{soln}
\end{itemize}
\end{itemize}
\end{document}
However, I have actually managed to find the problem myself. It seems my caption title is too long so it's not aligning strictly at the solution point. Furthermore, the caption title for the figure isn't actually aligning to space set out by the itemize environment within each item. It's as if the figure is centering to the document center instead of the slightly indented center within the itemize environment.
\noindent \par
. The\par
wipes out the\noindent
, so when the ext begins it will be indented to the distance of\parindent
. Although you've said that is set to zero, there isn't enough code in context to check what's really happening.itemize
so that\listparindent
is in effect, which is not touched by\setlength{\parindent}{0mm}
.\begin{figure}...\end{figure}
are floats; even though you specified[H]
, their original intent is for them to move around and fit into wherever there is space. In particular, it would make no sense for floating figures to obey "local indentation" rules.