Math & ScienceMath enviroments

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Toubob
Posts: 5
Joined: Sun Apr 26, 2015 3:08 pm

Math enviroments

Post by Toubob »

Hello,

I'm trying to optimize my math article. I wrote enviroments for definitions, theorems, and so on...
I like to shade the backround of a theorem or definiton. But I'm not able to set the headline in the shaded box. I uploaded a picture with an example.

Code: Select all

\newcounter{number}
\newenvironment{defi}[1][~]
{\refstepcounter{number}
\underline{\textbf{Definition~\Roman{number}}
}
\begin{shaded*}}
{\end{shaded*}}
Greetings
Attachments
Bildschirmfoto 2015-04-26 um 15.15.30.png
Bildschirmfoto 2015-04-26 um 15.15.30.png (28.26 KiB) Viewed 6682 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Math enviroments

Post by Johannes_B »

Hi and welcome,

please always post complete examples that can be testet instead of snippets.

Code: Select all

\documentclass{article}
\usepackage{mathtools}
\usepackage{blindtext}
\usepackage{xcolor}
\usepackage{mdframed}
\usepackage{amsthm}
\newtheoremstyle{toubob}%
{3pt}{3pt}{}{}{\bfseries}{:}{\newline}{}
\theoremstyle{toubob}
\newtheorem{defi}{Definition}
\surroundwithmdframed[backgroundcolor=green!20!white]{defi}
\begin{document}
\blindtext
\begin{defi}
	This is a simple test without any maths.\par
	Das ist ein simpler Test ohne Mathe.
\end{defi}
\end{document}

To the question why the shaded box does not include the header. Take a look at the code and read it out loud.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10359
Joined: Mon Mar 10, 2008 9:44 pm

Math enviroments

Post by Stefan Kottwitz »

Hi Toubob,

welcome to the forum!

I see you are writing in German - you are also welcome to post to our German partner site TeXwelt.de.

Stefan
LaTeX.org admin
Toubob
Posts: 5
Joined: Sun Apr 26, 2015 3:08 pm

Re: Math enviroments

Post by Toubob »

Thank you Johannes! Is it possible to use one counter for different theorems (corollary, theorem, definition) but with one counter and roman numbers in the headline?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Math enviroments

Post by Johannes_B »

To be honest, i wouldn't use roman numbers here. If your document gets long, this will be a mess. There is a reason why the roman numbering system didn't catch on ;-)

Code: Select all

\documentclass{article}
\usepackage{mathtools}
\usepackage{blindtext}
\usepackage{xcolor}
\usepackage{mdframed}
\usepackage{amsthm}
\newtheoremstyle{toubob}%
{3pt}{3pt}{}{}{\bfseries}{:}{\newline}{}
\theoremstyle{toubob}
\newtheorem{defi}{Definition}
\newtheorem{touthm}[defi]{Theorem}%use the same counter as defi
\renewcommand{\thedefi}{\roman{defi}}
\surroundwithmdframed[backgroundcolor=green!20!white]{defi}
\begin{document}
\blindtext
\begin{touthm}
	This is a simple definition test without any maths.\par
	Das ist ein simpler Test ohne Mathe.
\end{touthm}
\begin{defi}
	This is a simple theoremtest without any maths.\par
	Das ist ein simpler Test ohne Mathe.
\end{defi}

Now we have quite a lot of text, many definitions, theorems and
other stuff.
\setcounter{defi}{84}
\begin{touthm}
	This is a simple theorem test without any maths.\par
	Das ist ein simpler Test ohne Mathe.
	\label{thm:large}
\end{touthm}
As we can see in theorem~\ref{thm:large}, the number is ugly,
even more if uppercased.
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Toubob
Posts: 5
Joined: Sun Apr 26, 2015 3:08 pm

Re: Math enviroments

Post by Toubob »

Thanks to you Johannes, again. I know what you mean with the roman letters but for that one work, I need it. Know I'm happy with the result. My last question is, how to set a bit more space between the black border of the theorem and the headline? Just a bit, so that it's the same as it is between the last text line and the bottom borderline.

Greetings,
Toubob
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Math enviroments

Post by Johannes_B »

I am not quite sure which spaces you explicitely mean.
Within the theorem environment, you can control vertical spacing with the first two arguments.
If you surround something with package mdframed, the packages provides a whole bunch of its own commands to tweak the appearance.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Toubob
Posts: 5
Joined: Sun Apr 26, 2015 3:08 pm

Re: Math enviroments

Post by Toubob »

I mean that space.
Attachments
Bildschirmfoto 2015-04-27 um 23.32.48.png
Bildschirmfoto 2015-04-27 um 23.32.48.png (45.21 KiB) Viewed 6640 times
Toubob
Posts: 5
Joined: Sun Apr 26, 2015 3:08 pm

Re: Math enviroments

Post by Toubob »

I've got it ^^ As you said I set the first argument to 10pt. Thanks
Post Reply