Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

Desired output

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.

Undesired output

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.

Unexpected output

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.

Increased indentation

Could you please explain me the role of \hskip \labelsep here and help me to understand why each output appears the way it does?

share|improve this question
    
related definitive-guide-to-trivlists –  cmhughes Sep 11 '12 at 22:12
add comment

1 Answer 1

up vote 6 down vote accepted

trivlist sets \leftmargin and \labelwidth to 0pt, and \labelsep to 5pt.

In case 1 you are simply adding some length (\labelsep, which has a default value of 5pt) before the label; so you push the label ("Theorem" in your example) to the right by a value of 5pt; hadn't you added this length, the label would protrude 5pt 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 be 1in-5pt away from the left margin of the document.

In case 2 you have the default behaviour of trivlist; since \labelsep is 5pt, the leftmost character of the label will be pushed 5pt to the left and will protrude 5pt 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 to 1in the label will be pushed to the left and will be separated from the item body by this value; the default label will protrude 1in to the left of your document; however, since you used \hskip\labelsep inside the label, the label ("Theorem") will be pushed to the right 1in; 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 be 1in (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 for geometry only was used to show the left margin of the document:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{amsthm}

\newtheorem*{theorem}{Theorem}

\newcommand\Text{{\itshape Lorem Ipsum.}}

\begin{document}

\noindent Case 1:
\begin{trivlist}
\item[\hskip \labelsep\textbf{Theorem.}]\Text
\end{trivlist}

\noindent Case 2:
\begin{trivlist}
\item[\textbf{Theorem.}]\Text
\end{trivlist}
\vskip-\baselineskip\llap{\rule{5pt}{3pt}}
\vskip\baselineskip

{
\noindent Case 3:
\setlength{\labelsep}{1in}
\begin{trivlist}
\item[\hskip\labelsep\textbf{Theorem.}]\Text
\end{trivlist}
\vskip-\baselineskip{\bfseries Theorem.}\rule{1in}{3pt}\Text
\vskip\baselineskip
}

\noindent Case 4:
\begin{trivlist}
\item[\hskip 1in\textbf{Theorem.}]\Text
\end{trivlist}
\vskip-\baselineskip\rule{\dimexpr1in-5pt\relax}{3pt}{\bfseries Theorem.} \Text

\end{document}

enter image description here

In the LaTeX kernel one finds the following definitions for the default theorem-like structures built with \newtheorem:

\def\@begintheorem#1#2{\trivlist
  \item[\hskip\labelsep{\bfseries #1\ #2}]\itshape}
\def\@opargbegintheorem#1#2#3{\trivlist
  \item[\hskip \labelsep{\bfseries #1\ #2\ (#3)}]\itshape}

Since the defualt value for \labelsep in trivlist is 5pt, 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:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{amsthm}
\usepackage{layouts}

\newtheorem*{theorem}{Theorem}

\newcommand\Text{{\itshape Lorem Ipsum.}}

\begin{document}

\begin{trivlist}
\item[a]\Text
\currentlist
\begin{figure}
\listdesign
\caption{Layout of current list}
\end{figure}
\end{trivlist}

\clearpage

\begin{trivlist}
\item[a]\Text
\item[\hskip\labelsep\textbf{Theorem.}]\Text
\currentlist
\begin{figure}
\listdesign
\caption{Layout of current list}
\end{figure}
\end{trivlist}

\clearpage

\begin{trivlist}
\item[a]\Text
\item[\hskip 1in\textbf{Theorem.}]\Text
\currentlist
\begin{figure}
\listdesign
\caption{Layout of current list}
\end{figure}
\end{trivlist}

\clearpage

\setlength{\labelsep}{1in}
\begin{trivlist}
\item[a]\Text
\item[\hskip\labelsep\textbf{Theorem.}]\Text
\currentlist
\begin{figure}
\listdesign
\caption{Layout of current list}
\end{figure}
\end{trivlist}

\end{document}

As a final note, \itshape is a switch in declarative form, to be used in the following form

 \itshape text 

or

{\itshape text}

to keep the effect local to the group.

share|improve this answer
    
Thank you for the detailed answer. This helped me to understand the necessity of \hskip \labelsep very well. –  Susam Pal Sep 11 '12 at 21:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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