3

I need to create this:

enter image description here

I have a LaTeX file with this code, but I can't use styles to file with text:

\newlength\sidebar
\newlength\envrule
\newlength\envborder

\addtolength{\voffset}{-0.7in}
\addtolength{\textheight}{1.5in}

\setlength\sidebar{1.5mm}
\setlength\envrule{0.4pt}
\setlength\envborder{2.5mm}

\definecolor{noteborder}{rgb}{.5,.5,.5}
\definecolor{notebg}{rgb}{.95,.95,.95}
\definecolor{exampleborder}{rgb}{.22,.22,.555}
\definecolor{examplebg}{rgb}{.9,.9,1}
\definecolor{statementborder}{rgb}{.9,0,0}
\definecolor{statementbg}{rgb}{1,.9,.9}
\definecolor{theoremborder}{rgb}{0,0,0}
\definecolor{theorembg}{rgb}{.77,.88,.66}
\definecolor{ruzova}{rgb}{1,0.8,0.8}
\definecolor{zluta}{rgb}{1,1,0.5}
\definecolor{hrasek}{rgb}{0.79,1,0.45}

\newsavebox\envbox

\definecolor{red}{rgb}{0.9, 0, 0}

\newcounter{prik}[section] 
\renewcommand{\theprik}{\thesection.\arabic{prik}} 
\newcommand{\priklad}[1]{\refstepcounter{prik}\paragraph*{Příklad \theprik} #1} 

\newcounter{veta}[section]

\newenvironment{veta}[1][]{%
\par
\refstepcounter{veta}%

%\SpecialEnv{#1}{OliveGreen}{theorembg}{}{}%
\SpecialEnv{#1}{green!50!black}{theorembg}{}{}%
}{%
\endSpecialEnv
}

\newenvironment{statement}[1][]{% Default statement has no title
\par
\SpecialEnv{#1}{statementborder}{statementbg}{statementborder}{}%
}{%
\endSpecialEnv
}


\def\Empty{}

% #1 title (if any)
% #2 sidebar (and title bg) color
% #3 background color
% #4 border color (or null for no border)
% #5 Counter, if any.
\newenvironment{SpecialEnv}[5]{%
\par
\def\EnvSideC{#2}% To use later (in end)
\def\EnvBackgroundC{#3}%
\def\EnvFrameC{#4}%
\flushleft


\setlength\leftskip{-\sidebar}%
\addtolength\leftskip{-\envborder}%
\noindent \nobreak
% Check if title is null:
\ifx\delimiter {VÃTA \thesection.\theveta\ #1}\delimiter\else
% If a title is specified, then typeset it in reverse color
\colorbox{\EnvSideC}{%
\hspace{-\leftskip}% usually positive
\hspace{-\fboxsep}%
\footnotesize\sffamily\bfseries\textcolor{white}{VÃTA \thesection.\theveta\ #1}%
\hspace{\envborder}}%
\par\nobreak
\setlength\parskip{-0.2pt}% Tiny overlap to counter pixel round-off errors
\nointerlineskip
\fi


% Make side-bar
\textcolor{\EnvSideC}{\vrule width\sidebar}%
% collect body in \envbox:
\begin{lrbox}\envbox
\begin{minipage}{\hsize}%


% insert counter, if any:
\ifx\delimiter#5\delimiter\else
\theveta.\enspace
\fi
\ignorespaces
}{\par
\end{minipage}\end{lrbox}%
% body is collected. Add background color
\setlength\fboxsep\envborder
\ifx\EnvFrameC\Empty % no frame
\colorbox{\EnvBackgroundC}{\usebox\envbox}%
\else % frame
\setlength\fboxrule\envrule
\addtolength\fboxsep{-\envrule}%
\fcolorbox{\EnvFrameC}{\EnvBackgroundC}{\usebox\envbox}%
\fi
\nobreak \hspace{-2\envborder}\null
\endflushleft
}

%************************************************************************

\newcounter{definice}[section]

\newenvironment{definice}[1][DEFINICE \thesection.\thedefinice]{%                               %
\par
\refstepcounter{definice}%

%\SpecialEnva{#1}{RedOrange}{statementbg}{}{}%
\SpecialEnva{#1}{red!70}{red!15}{}{}%
}{%
\endSpecialEnva
}

\newenvironment{statementa}[1][]{% Default statement has no title
\par
\SpecialEnva{#1}{statementborder}{statementbg}{statementborder}{}%
}{%
\endSpecialEnva
}


\def\Empty{}

% #1 title (if any)
% #2 sidebar (and title bg) color
% #3 background color
% #4 border color (or null for no border)
% #5 Counter, if any.
\newenvironment{SpecialEnva}[5]{%
\par
\def\EnvSideC{#2}% To use later (in end)
\def\EnvBackgroundC{#3}%
\def\EnvFrameC{#4}%
\flushleft


\setlength\leftskip{-\sidebar}%
\addtolength\leftskip{-\envborder}%
\noindent \nobreak
% Check if title is null:
\ifx\delimiter#1\delimiter\else
% If a title is specified, then typeset it in reverse color
\colorbox{\EnvSideC}{%
\hspace{-\leftskip}% usually positive
\hspace{-\fboxsep}%
\footnotesize\sffamily\bfseries\textcolor{white}{#1}%
\hspace{\envborder}}%
\par\nobreak
\setlength\parskip{-0.2pt}% Tiny overlap to counter pixel round-off errors
\nointerlineskip
\fi


% Make side-bar
\textcolor{\EnvSideC}{\vrule width\sidebar}%
% collect body in \envbox:
\begin{lrbox}\envbox
\begin{minipage}{\hsize}%


% insert counter, if any:
\ifx\delimiter#5\delimiter\else
\thedefinice.\enspace
\fi
\ignorespaces
}{\par
\end{minipage}\end{lrbox}%
% body is collected. Add background color
\setlength\fboxsep\envborder
\ifx\EnvFrameC\Empty % no frame
\colorbox{\EnvBackgroundC}{\usebox\envbox}%
\else % frame
\setlength\fboxrule\envrule
\addtolength\fboxsep{-\envrule}%
\fcolorbox{\EnvFrameC}{\EnvBackgroundC}{\usebox\envbox}%
\fi
\nobreak \hspace{-2\envborder}\null
\endflushleft
}


%************************************************************************

\newcounter{poznamka}[section]

\newenvironment{poznamka}[1][POZN¡MKA \thesection.\thepoznamka]{%
\par
\refstepcounter{poznamka}%

\SpecialEnvb{#1}{noteborder}{notebg}{}{}%
}{%
\endSpecialEnvb
}

\newenvironment{statementb}[1][]{% Default statement has no title
\par
\SpecialEnvb{#1}{statementborder}{statementbg}{statementborder}{}%
}{%
\endSpecialEnvb
}


\def\Empty{}

% #1 title (if any)
% #2 sidebar (and title bg) color
% #3 background color
% #4 border color (or null for no border)
% #5 Counter, if any.
\newenvironment{SpecialEnvb}[5]{%
\par
\def\EnvSideC{#2}% To use later (in end)
\def\EnvBackgroundC{#3}%
\def\EnvFrameC{#4}%
\flushleft


\setlength\leftskip{-\sidebar}%
\addtolength\leftskip{-\envborder}%
\noindent \nobreak
% Check if title is null:
\ifx\delimiter#1\delimiter\else
% If a title is specified, then typeset it in reverse color
\colorbox{\EnvSideC}{%
\hspace{-\leftskip}% usually positive
\hspace{-\fboxsep}%
\footnotesize\sffamily\bfseries\textcolor{white}{#1}%
\hspace{\envborder}}%
\par\nobreak
\setlength\parskip{-0.2pt}% Tiny overlap to counter pixel round-off errors
\nointerlineskip
\fi


% Make side-bar
\textcolor{\EnvSideC}{\vrule width\sidebar}%
% collect body in \envbox:
\begin{lrbox}\envbox
\begin{minipage}{\hsize}%


% insert counter, if any:
\ifx\delimiter#5\delimiter\else
\thepoznamka.\enspace
\fi
\ignorespaces
}{\par
\end{minipage}\end{lrbox}%
% body is collected. Add background color
\setlength\fboxsep\envborder
\ifx\EnvFrameC\Empty % no frame
\colorbox{\EnvBackgroundC}{\usebox\envbox}%
\else % frame
\setlength\fboxrule\envrule
\addtolength\fboxsep{-\envrule}%
\fcolorbox{\EnvFrameC}{\EnvBackgroundC}{\usebox\envbox}%
\fi
\nobreak \hspace{-2\envborder}\null
\endflushleft
}








\newcounter{obr}[section]
\newcommand{\newobr}{\arabic\thesection.\arabic{obr}}
\def\obrazek#1#2#3{%
 \begin{minipage}{10cm}
 \refstepcounter{obr}
    \begin{center}\scalebox{#1}{%
        \includegraphics*{#2}
        }\\
        \begin{center}Obr·zek \thesection.\arabic{obr} {\it #3}\end{center}
    \end{center}
    \end{minipage}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcounter{dusledek}[section]

\newenvironment{dusledek}[1][DŸSLEDEK \thesection.\thedusledek]{%
\par
\refstepcounter{dusledek}%

\SpecialEnvc{#1}{exampleborder}{examplebg}{}{}%
}{%
\endSpecialEnvc
}

\newenvironment{statementc}[1][]{% Default statement has no title
\par
\SpecialEnvc{#1}{statementborder}{statementbg}{statementborder}{}%
}{%
\endSpecialEnvc
}


\def\Empty{}

% #1 title (if any)
% #2 sidebar (and title bg) color
% #3 background color
% #4 border color (or null for no border)
% #5 Counter, if any.
\newenvironment{SpecialEnvc}[5]{%
\par
\def\EnvSideC{#2}% To use later (in end)
\def\EnvBackgroundC{#3}%
\def\EnvFrameC{#4}%
\flushleft


\setlength\leftskip{-\sidebar}%
\addtolength\leftskip{-\envborder}%
\noindent \nobreak
% Check if title is null:
\ifx\delimiter#1\delimiter\else
% If a title is specified, then typeset it in reverse color
\colorbox{\EnvSideC}{%
\hspace{-\leftskip}% usually positive
\hspace{-\fboxsep}%
\footnotesize\sffamily\bfseries\textcolor{white}{#1}%
\hspace{\envborder}}%
\par\nobreak
\setlength\parskip{-0.2pt}% Tiny overlap to counter pixel round-off errors
\nointerlineskip
\fi


% Make side-bar
\textcolor{\EnvSideC}{\vrule width\sidebar}%
% collect body in \envbox:
\begin{lrbox}\envbox
\begin{minipage}{\hsize}%


% insert counter, if any:
\ifx\delimiter#5\delimiter\else
\thedusledek.\enspace
\fi
\ignorespaces
}{\par
\end{minipage}\end{lrbox}%
% body is collected. Add background color
\setlength\fboxsep\envborder
\ifx\EnvFrameC\Empty % no frame
\colorbox{\EnvBackgroundC}{\usebox\envbox}%
\else % frame
\setlength\fboxrule\envrule
\addtolength\fboxsep{-\envrule}%
\fcolorbox{\EnvFrameC}{\EnvBackgroundC}{\usebox\envbox}%
\fi
\nobreak \hspace{-2\envborder}\null
\endflushleft
}

Can you tell me how it do it? :)

1
  • I'm glad you got your answer, but this is quite possibly the least minimal minimal working example I've ever seen. If you trim it to what's really necessary, you'll be helping people help you. dickimaw-books.com/latex/minexample Mar 12, 2015 at 2:29

1 Answer 1

9

You can use the tcolorbox package:

\documentclass{book}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}

\definecolor{mybox}{RGB}{246,51,46}

\newtcolorbox[auto counter,number within=section]{mydefi}{
  enhanced,
  breakable,
  arc=0pt,
  outer arc=0pt,
  rightrule=0pt,
  toprule=0pt,
  bottomrule=0pt,
  leftrule=3pt,
  colframe=mybox,
  colback=mybox!30,
  attach boxed title to top left,
  boxed title style={size=small,colback=red,arc=0pt,outer arc=0pt,colupper=white},
  title=Definice~\thetcbcounter,
}

\begin{document}

\begin{mydefi}
\lipsum[1]
\end{mydefi}

\end{document}

enter image description here

1
  • @Viktor You're welcome! Don't forget that you can accept the answer, if you consider it solved your proble, by clicking the checkmark to its left; in case of doubt, please see How do you accept an answer?. Mar 12, 2015 at 14:04

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.