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.

When I write a tutorial for my students, it is always plane and simple by using the predefined section style of the article class. I looked at some other posts and saw that the code below changes the font style of the section to small caps.

 \documentclass[letterpaper]{article}
 \usepackage{lipsum}
 \makeatletter
 \renewcommand{\section}{\@startsection {section}{1}{0pt}%
 {-3.5ex plus -1ex minus -.2ex}%
 {2.3ex plus .2ex}%
 {\normalfont\Large\scshape}}
 \makeatother
 \begin{document}
 \section{test}
 \lipsum[1-3]
 \end{document}

But then I see in some of the textbooks my students use the following image: enter image description here

I was wondering if you can assist me in understanding the process of editing the section style.

share|improve this question
4  
Please don't ask "How do I achieve this layout", but rather a question about a specific feature that you're struggling with, one problem per question. This way other users who have a similar problem can benefit from your question and the solutions to it (No one's gonna ask for the same layout as you). It's no problem to ask several questions, if you've made some attempt yourself first. It's enormously helpful to see what you've tried so far to figure out what doesn't work. –  doncherry Feb 22 '12 at 17:19
    
@doncherry I am struggling in understanding the editing of a predefined section style like that of the article document class. I will edit my question. –  azetina Feb 22 '12 at 19:13
add comment

3 Answers 3

Here an other approach with mdframed.

\documentclass{article}
\usepackage{showframe}
\usepackage{enumitem}
\usepackage[framemethod=default]{mdframed}
\usepackage{tikz}
\mdfdefinestyle{conclusion}{%
innerleftmargin=0.3\linewidth,
innerrightmargin=1cm,
leftline=false,
rightline=false,
backgroundcolor=yellow!20,
linecolor=blue,
linewidth=4pt,
skipabove=\dimexpr\topskip+.5cm\relax,
settings={\setlist[itemize]{label=\color{red!60!black}\rule[.25ex]{1ex}{1ex}}%
               \refstepcounter{section}},
frametitleaboveskip=\dimexpr-1.5\ht\strutbox\relax,
frametitle=%
 {%
  \null\llap{%
     \tikz[baseline=(current bounding box.east),outer sep=0pt,remember picture]
      \node[anchor=west,
             xshift=0cm,rectangle,fill=red!60!black,
             rounded corners,
             font=\color{white}\Large\sffamily] (frametitle)%
                                                                 {section~\thesection};
               }%
  }
}

\newmdenv[style=conclusion]{conclusion}

\begin{document}
Text Text
\begin{conclusion}
\begin{itemize}
\item Evaluate a logarithm using the change-of-base formula.
\item Use properties of logarithms to evaluate or rewrite a logarithmic expression
\item \ldots
\end{itemize}
\end{conclusion}
\end{document}

enter image description here

share|improve this answer
add comment

This doesn't pretend to meet any typographic guidelines, but it shows how to start, basically use the definition of \part rather than \section as the basis if you want to use extra styling. it would need the version for the *-ed form defining. Also I've just used basic colorpackage here (as I know something about that) more exotic effects can be gained with colorx or tikz, and minitoc has loads of options, none of which I have used...

enter image description here

\documentclass{report}
%% minitoc handless per-section tables of contents 
%% color handles colour
\usepackage{minitoc,color}

%% use @ in command names (not needed in a package file)
\makeatletter


%% almost exactly how article.sty defines \part
\def\section{%
   \if@noskipsec \leavevmode \fi
   \par
   \addvspace{4ex}%
   \@afterindentfalse
   \secdef\@mysec\@smysec}


%% The normal form \@smysec would need to be defined
%%  to do the * form so no number ie no
%%  \refstepcounter and possibly no red box
%% [#1] is the optional short form #2 is the main title   
\def\@mysec[#1]#2{%
%% bump the counter
      \refstepcounter{section}%
%% add to the toc
      \addcontentsline{toc}{section}{\thepart\hspace{1em}#1}%
%% some vertical space 
      \bigskip
%% make sure the whole construct stays together not split over a page
      \vbox{%
%% a blue line
      \noindent\textcolor{blue}{\vrule \@height 3pt \@width\linewidth}%
%% back up
      \hspace{-0.75\linewidth}%
%% a red box with some white text
      \colorbox{red}{\color{white}{\normalfont\bfseries\large Section \thesection}}%
      \par
%% this was left in by mistake, but I'll leave it in as that's what
%% made the image
      \vskip -3pt
%% two side by side boxes one for the title and one for minitoc
       \noindent
%% #2 is the title
       \begin{minipage}[t]{0.3\linewidth}\raggedright\large\color{blue}
          \bigskip#2\end{minipage}%
%%  \minitoc makes this sections toc (minitoc package)
       \begin{minipage}[t]{0.7\linewidth}\small\minitoc\end{minipage}%
}%
%%    finish up, again same as \part in article.sty
%%    \@afterheading gets latex to try to keep the next text
%% on same page and by default supresses indentation of the first para
    \nobreak
    \vskip 3ex
    \@afterheading}




\begin{document}
\dominitoc
\tableofcontents


\chapter{hmmmm}

\section{Properties of Logarithms}

blah blah

\subsection{Evaluate a logarithm using\ldots}
blah blah
\subsection{Use properties of logarithms \ldots\ evaluate}
blah blah
\subsection{Use properties of logarithms\ldots\ expand}
blah blah
\subsection{Use logarithmic functions\ldots}
blah blah

\end{document}
share|improve this answer
    
Incredible output. Can you elaborate on how you managed to achieve such a design. I want to understand how to edit the section style. Probably an explanation on the steps undertaken would greatly assist. –  azetina Feb 22 '12 at 19:19
    
Comments added, see %% in edited answer. –  David Carlisle Feb 22 '12 at 20:41
add comment

Shapes, Color and positioning - I would use TikZ for that. A possible approach:

  • Use nodes for section number and section heading
  • Define styles for each element, such as those nodes and the bullets for the subsections, such as

    \tikzset{section/.style={rectangle, rounded corners,fill=red, inner sep=4pt}}
    
  • Use the baseline option for aligning node content and surrounding text at their base line

  • Refer to the current page node for drawing the line from the left to the right
  • Name section nodes using the section counter, such as

    \tikz[baseline=(\thesection.base)] \node (\thesection) [section]{#1};}
    
  • Use minitoc and combine it with TikZ styling

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.