TransWikia.com

Help: How to create a red line margin at example environment

TeX - LaTeX Asked by Joey Adams on December 27, 2020

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

One Answer

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}quadbegin{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 foopar bahpar baz
end{eks}
end{document}

Answered by Fran on December 27, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP