[OS X TeX] Special Horizontal Rule

Alan Munn amunn at msu.edu
Fri Dec 25 03:55:06 CET 2009


At 4:17 PM -0800 12/24/09, David Arnold wrote:
>All, 
>
>I'd like to adjust my example environment in the code below so that 
>each example is bracketed between two horizontal rules. The first rule 
>should be placed above the example, align with the inner edge of the 
>text and flow to the outer edge of the text, add a couple of spaces in 
>the outer margin, typeset "You Try It", then continue to flow to 
>within 1 cm of the page edge. 
>
>Similarly, for the rule at the bottom of the example, I'd like to 
>start it at the inner edge of the text, flow into the outer margin, 
>then typeset the square that is flush right within 1 cm of the paper 
>edge. 
>
>Can anyone help with an example?

This should get you started.  The basic idea is to put the rule 
inside a parbox which won't break; this allows it to overshoot the 
margins (you'll get overfull hbox warnings, but that's fine in this 
context.)  I don't have the exerquiz package, so I commented it out.

You'll probably want to mess around with the length of the second bar 
to fit your needs. I raised the rule to align with the center of the 
text instead of being on the baseline.

Merry Christmas!

Alan


\documentclass{memoir}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{calc}

\usepackage{xcolor}
%\usepackage{exerquiz}
\newlength{\barwidth}
\setlength{\barwidth}{\textwidth+\marginparwidth}

\usepackage{xcolor}
\definecolor{shadecolor}{gray}{0.9}
\definecolor{darkgreen}{rgb}{0,0.625,0}
\definecolor{darkred}{rgb}{0.625,0,0}

\newcounter{example}[section]
\renewcommand{\theexample}{\arabic{example}}
\newenvironment{example}%
{\medskip\refstepcounter{example}\noindent\parbox{\barwidth}{{\color{darkgreen}\rule[.5ex]{\textwidth}{1pt}\ 
You try it!\ \rule[.5ex]{1cm}{1pt}}}
   \par\noindent\textbf{Example \theexample.}}%
{\noindent\parbox{\barwidth}{{\color{darkgreen}\rule[.5ex]{.9\barwidth}{1pt}\ 
\Large$\square$\ \par\medskip}}}

\begin{document}

\section{Introduction}

Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.

\begin{example}
\marginpar{You Try It!\newline Simplify: $33+28$}
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
\end{example}

Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.

\end{document}
-- 
Alan Munn						amunn at msu.edu
Department of Linguistics
and Germanic, Slavic, Asian and African Languages		Tel. 
	517-355-7491
Michigan State University, East Lansing MI 48824 USA	Fax	517-432-2736



More information about the macostex-archives mailing list