0

I'm working on an example document for a book that I bought for my girlfriend. The book does not have any examples inside and I want to make a note such that she can see how the math works.

Down below you can see a picture of how my code:

\documentclass[12pt,oneside,final]{report}


\newenvironment{eks}[2][Example]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}

\begin{document}


\chapter{Linear Algebra}
\section{Vectors}



\begin{eks}{}
Let $X$ be...
\end{eks}


\section{Matrices}



\begin{eks}{}
Let $X$ be...
\end{eks}


\end{document}

works.

enter image description here

Now to my question. First, I don't know how to create a line at left margin in my example environment. I've tried by reading on the internet for some useful packages and also readed on this page.

The next thing is how can I make a pattern for my example? My picture above only show "Example" in each section. I wan't it to look like "Example 1.1.1" and for the second section, "Example 1.2.1" and so on. Down below you can see my idea on how it should look like. (It is made in MSPaint).

enter image description here

2

1 Answer 1

1

Tkiz, mdframed for tcolorbox for a simple rule? The Spanish expression for this could be "Killing flies with cannon shots" (matar moscas a cañonazos).

\documentclass[12pt,oneside,final]{report}
\usepackage{xcolor}
\newenvironment{eks}[2][Example]{\hskip-1.15em{\color{red}%
\vrule width .15em}\quad\begin{minipage}{\linewidth}%
\begin{trivlist}\item[\hskip \labelsep {\bfseries #1}%
\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}%
\end{minipage}}

\begin{document}
\chapter{Linear Algebra}
\section{Vectors}
\begin{eks}{}
Let $X$ be...
\end{eks}
\section{Matrices}
\begin{eks}{foo}
Let $X$ be...\par foo\par bah\par baz
\end{eks}
\end{document}
2
  • Germans say “to shoot with cannons at sparrows” :)
    – cgnieder
    Feb 12, 2021 at 12:29
  • French people say "Utiliser un marteau-pilon pour écraser une mouche" that translates to "Using a sledgehammer to swat a fly" : -)
    – Jhor
    Jul 21 at 11:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .