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'm editing a book. What I want is a sectioning command like \section, \subsection, and friends, to typeset a exercises section at the end of each section of the book. This exercises are in some list environments, and I don't want any additional features to the exercises itself.

I don't want to redefine some of the mentioned commands because I need to use all of them along the edition of the book. So, what I have tried

\documentclass[12pt,letterpaper]{book}
\usepackage[latin1]{inputenc}
\usepackage[spanish]{babel}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\renewcommand\headrulewidth{0pt}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}     
\renewcommand{\sectionmark}[1]{\markright{#1}{}}
\fancyhead[LO]{\small\textsl{\leftmark}}            
\fancyhead[RE]{\small\textsl{\rightmark}}           
\fancyhead[LE,RO]{\thepage}                         

\newenvironment{ejercicios}{
\newpage

\vspace{0.5cm}

\rule{\textwidth}{0.5pt}
\makebox[\textwidth][r]{\Large Ejercicios \thesection. \rightmark}
\rule{\textwidth}{0.5pt}

\vspace{0.5cm}
}{\newpage}

The problem is that the space between the rules and the text are distinct. I've tried to use \parbox and try to adjust the spaces between the rules and the text, but this never work because I need (on request to me) the following:

\makeatletter 
\renewcommand\paragraph{\@startsection
{paragraph}{3}{0cm}             
{0cm}                           
{3mm}                   
{\bf}}  
\makeatother 

It is to break the line after each paragraph header, I suspect that this affect the use of \parbox.

Whatever, my attempt to solution this is inelegant. I want something like \newsectioncommand that be independent of the behavior of the \paragraph command.

That I want is something that produce

a new page

5mm

rule

3mm

aligned right Ejercicios "section number". "section name"

3mm

rule

5mm

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

In the following minimal working example (MWE), the command \sectionexercises that prints your required "Exercises" layout for the preceding section

enter image description here

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage[showframe]{geometry}% http://ctan.org/pkg/geometry
\renewcommand{\sectionmark}[1]{\markright{#1}{}}
\newcommand{\sectionexercises}{%
  \newpage%
  \kern 5mm
  \hrule
  \kern 3mm
  \null \hfill Ejercicios~\thesection.~\rightmark\par
  \kern 3mm
  \hrule
  \kern 5mm
}
\begin{document}
\section{First section}\lipsum[1-2]
\sectionexercises
\begin{enumerate}
  \item Here is a question.
  \item Here is a question.
  \item Here is a question.
  \item Here is a question.
  \item Here is a question.
\end{enumerate}
\end{document}

The lipsum package provides dummy text, while geometry was loaded with the showframe package option to highlight the text block borders.

The nameref package provides a more generic way of tapping into sectional titles if you're going to have (say) many sections before typesetting some of the exercises. In that case, you could modify the MWE in the following way:

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage[showframe]{geometry}% http://ctan.org/pkg/geometry
\usepackage{nameref}% http://ctan.org/pkg/nameref
\newcommand{\sectionexercises}[1]{%
  \newpage%
  \kern 5mm
  \hrule
  \kern 3mm
  \null \hfill Ejercicios~\thesection.~\nameref{#1}\par
  \kern 3mm
  \hrule
  \kern 5mm
}
\begin{document}
\section{First section}\label{sec:first}\lipsum[1-2]
\sectionexercises{sec:first}
\begin{enumerate}
  \item Here is a question.
  \item Here is a question.
  \item Here is a question.
  \item Here is a question.
  \item Here is a question.
\end{enumerate}
\end{document}

This produces the same result as before, with \sectionexercises{<lab>} now taking a label <lab> of the corresponding section.

share|improve this answer
    
Thanks, that's great. –  leo Oct 23 '11 at 20:19
add comment

I suggest you consider Don Story's fortextbook option of his eqexam package. http://www.math.uakron.edu/~dpstory/eqexam.html

share|improve this answer
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.