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.

 \renewcommand{\section}{\@startsection {section}{1}{0pt}%
 {-3.5ex plus -1ex minus -.2ex}%
 {2.3ex plus .2ex}%

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.

  • 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

Here an other approach with mdframed.

     \tikz[baseline=(current bounding box.east),outer sep=0pt,remember picture]
             rounded corners,
             font=\color{white}\Large\sffamily] (frametitle)%


Text Text
\item Evaluate a logarithm using the change-of-base formula.
\item Use properties of logarithms to evaluate or rewrite a logarithmic expression
\item \ldots

enter image description here


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

%% minitoc handless per-section tables of contents 
%% color handles colour

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

%% almost exactly how article.sty defines \part
   \if@noskipsec \leavevmode \fi

%% 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   
%% bump the counter
%% add to the toc
%% some vertical space 
%% make sure the whole construct stays together not split over a page
%% a blue line
      \noindent\textcolor{blue}{\vrule \@height 3pt \@width\linewidth}%
%% back up
%% a red box with some white text
      \colorbox{red}{\color{white}{\normalfont\bfseries\large Section \thesection}}%
%% 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
%% #2 is the title
%%  \minitoc makes this sections toc (minitoc package)
%%    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
    \vskip 3ex



\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

  • 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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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