I am trying to learn how to create a theorem like environment from http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/Theorems.html
To keep the code below simple, I am not really defining a new environment but writing the actual inline code for what the environment should look like followed by a theorem environment to compare the output of my code with that of the theorem environment.
Case 1: \hskip \labelsep
only
Here is the code that works fine.
\documentclass{article}
\usepackage{amsthm}
\newtheorem*{theorem}{Theorem}
\begin{document}
% My environment
\begin{trivlist}
\item[\hskip \labelsep \textbf{Theorem.}]
\begin{itshape}
Lorem Ipsum.
\end{itshape}
\end{trivlist}
% Theorem environment for comparison
\begin{theorem}
Lorem Ipsum.
\end{theorem}
\end{document}
This produces the desired output as can be seen below.
Case 2: No \hskip \labelsep
I wanted to see why \hskip \labelsep
is necessary in the above code, so I removed it from my code.
\documentclass{article}
\usepackage{amsthm}
\newtheorem*{theorem}{Theorem}
\begin{document}
% My environment
\begin{trivlist}
\item[\textbf{Theorem.}]
\begin{itshape}
Lorem Ipsum.
\end{itshape}
\end{trivlist}
% Theorem environment for comparison
\begin{theorem}
Lorem Ipsum.
\end{theorem}
\end{document}
This does not produce the desired output. The indentation of my environment appears to be less than the indentation of the actual theorem environment.
This indicates that \hskip \labelsep
is necessary.
Case 3: \setlength{\labelsep}{1in}
along with \hskip \labelsep
I tried searching the web to understand why \hskip \labelsep
is necessary to get the correct indentation but couldn't find anything that made sense to me. I decided to find how varying \labelsep
affects the indentation.
\documentclass{article}
\usepackage{amsthm}
\newtheorem*{theorem}{Theorem}
\setlength{\labelsep}{1in}
\begin{document}
% My environment
\begin{trivlist}
\item[\hskip \labelsep \textbf{Theorem.}]
\begin{itshape}
Lorem Ipsum.
\end{itshape}
\end{trivlist}
% Theorem environment for comparison
\begin{theorem}
Lorem Ipsum.
\end{theorem}
\end{document}
This produces the output shown below.
In this output, the behaviour of \labelsep
seems to match what is described at http://www.troubleshooters.com/linux/lyx/ownlists.htm
\labelsep — The distance between the rightmost part of the label (assuming you haven't changed the label from its default right justification) to the left margin of the item body. This is one of the handiest adjustments you can make to create the ultimately readable list for your exact situation.
BEWARE: This setting enforces this distance by shoving the label left rather than moving the body left margin right. If you set this you might need to add a corresponding amount to \leftmargin, if you want your labels in a specific place.Use it early and often.
I was also expecting the indentation of my environment to be more than the indentation of the actual theorem environment, but as you can see in the output above, the indentation of my environment is same as that of the actual environment. I don't know if the 'BEWARE' note in the above documentation can explain this.
Case 4: \hskip 1in
only
However, if I just use \hskip 1in
instead of \hskip \labelsep
, I do see the increase in indentation that I expect.
\documentclass{article}
\usepackage{amsthm}
\newtheorem*{theorem}{Theorem}
\begin{document}
% My environment
\begin{trivlist}
\item[\hskip 1in \textbf{Theorem.}]
\begin{itshape}
Lorem Ipsum.
\end{itshape}
\end{trivlist}
% Theorem environment for comparison
\begin{theorem}
Lorem Ipsum.
\end{theorem}
\end{document}
The output below shows that the indentation of my environment is more than that of the actual theorem environment.
Could you please explain me the role of \hskip \labelsep
here and help me to understand why each output appears the way it does?
Best Answer
trivlist
sets\leftmargin
and\labelwidth
to0pt
, and\labelsep
to5pt
.In case 1 you are simply adding some length (
\labelsep
, which has a default value of5pt
) before the label; so you push the label ("Theorem" in your example) to the right by a value of5pt
; hadn't you added this length, the label would protrude5pt
into the left margin of the document (which is exactly what happens in case 2).Something similar happens in case 4, with the only difference that the horizontal length used to push the label to the right is
1in
; in this case, the leftmost character of the label will be1in-5pt
away from the left margin of the document.In case 2 you have the default behaviour of
trivlist
; since\labelsep
is5pt
, the leftmost character of the label will be pushed5pt
to the left and will protrude5pt
of the left margin of the document; the rightmost character of the label will be separated by the default\labelsep
value from the following text.The separation between the rightmost character of the label and the beginning of the item body in the three considered cases is
\labelsep
(5pt
).Case 3 is the only one in which the default value of
\labelsep
really changes; two things happen in this case: since you set\labelsep
to1in
the label will be pushed to the left and will be separated from the item body by this value; the default label will protrude1in
to the left of your document; however, since you used\hskip\labelsep
inside the label, the label ("Theorem") will be pushed to the right1in
; all in all, the leftmost character of the label will coincide with the left margin of the document and the rightmost character of the label will be1in
(the value set for\labelsep
) away from the following text.Here's a simple document in which I illustrate your four cases together, and the result just explained; I added some thick rules to help visualize the lengths given in the explanation; the
showframe
option forgeometry
only was used to show the left margin of the document:In the LaTeX kernel one finds the following definitions for the default theorem-like structures built with
\newtheorem
:Since the defualt value for
\labelsep
intrivlist
is5pt
, without the use of\item[\hskip\labelsep...]
the label for the theorems would protrude 5pt into the left margin of the document.One way to visualize what's going on in your example code (and in the design for particular layouts, in general) is to use the
layouts
package; the\currentlist
command can be used to extract the values for the different lengths in each of your example code:As a final note, \itshape is a switch in declarative form, to be used in the following form
or
to keep the effect local to the group.