5

I'm creating a new document based on another being successful, but it's too long to use as a MWE.

Anyway, I'm trying to create a new environment, but it's missing something I do not know what to look for.

This new environment is to get something like this:

enter image description here

MWE

\documentclass[11pt,fleqn]{book}

\usepackage[top=3cm,bottom=3cm,left=3cm,right=3cm,headsep=10pt,a4paper]{geometry}
\usepackage{blindtext}
\usepackage[portuguese]{babel}
\usepackage{avant}
\usepackage{mathptmx}
\usepackage{microtype}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{hyperref}
\usepackage{xcolor}

\definecolor{ocre}{RGB}{243,102,25}

\RequirePackage[framemethod=default]{mdframed}

%-------Etapa Box------------
\newmdenv[skipabove=7pt,
skipbelow=7pt,
rightline=false,
leftline=true,
topline=false,
bottomline=false,
backgroundcolor=ocre!10,
linecolor=ocre,
innerleftmargin=5pt,
innerrightmargin=5pt,
innertopmargin=5pt,
innerbottommargin=5pt,
leftmargin=0cm,
rightmargin=0cm,
linewidth=4pt]{eBox}
%------------------------------------------

%-------Hyperref and BookMark-------
\hypersetup{hidelinks,backref=true,pagebackref=true,hyperindex=true,colorlinks=false,breaklinks=true,urlcolor= ocre,bookmarks=true,bookmarksopen=false,pdftitle={Title},pdfauthor={Author}}
\usepackage{bookmark}

\bookmarksetup{
open,
numbered,
addtohook={%
\ifnum\bookmarkget{level}=0 % chapter
\bookmarksetup{bold}%
\fi
\ifnum\bookmarkget{level}=-1 % part
\bookmarksetup{color=ocre,bold}%
\fi
}
}

\renewcommand*{\thechapter}{%
  \texorpdfstring{}{\chaptername\space}\arabic{chapter}%
  \texorpdfstring{}{: }%
}
% Section numbers without prefix or the place for adding a prefix
% "Section".
\renewcommand*{\thesection}{%
  \arabic{chapter}.\arabic{section}%
}
%------------------------------------------

%----------New Theorem---------------
\newtheorem{etapaT}{Passo}[section]
%------------------------------------------

%-------New Environment------------
\newenvironment{etapa}{\begin{eBox}\begin{etapaT}}{\hfill{\color{ocre}\tiny\ensuremath{\blacksquare}}\end{etapaT}\end{eBox}}     
%------------------------------------------

\begin{document}

\tableofcontents

\chapter{Informações}
\section{Conversa informal}

    \begin{etapa}
Texto
    \end{etapa}

\end{document}
  • 1
    I think, you should use the more powerful tcolorbox package instead of mdframed here. Besides that, your example does not compile, and \RequirePackage is 'reserved' for packages rather than documents; but in total, I don't understand what you're after here – user31729 Oct 26 '17 at 18:38
  • Your MWE is almost fine, I would say. You should replace \RequirePackage with \usepackage. Then, in order to use \blacksquare, you have to load the package amssymb. Finally, you could shift the black square a bit, maybe with \raisebox{0.166em}{\blacksquare}. – Jasper Habicht Oct 26 '17 at 19:08
  • I changed the New Theorem by removing Chapter and inserting the section. – LCarvalho Oct 26 '17 at 19:44
1

Here I use tcolorbox instead of mdframed and apply one single environment for this.

\documentclass[11pt,fleqn]{book}

\usepackage[top=3cm,bottom=3cm,left=3cm,right=3cm,headsep=10pt,a4paper]{geometry}
\usepackage{blindtext}
\usepackage[portuguese]{babel}
\usepackage{avant}
\usepackage{mathptmx}
\usepackage{microtype}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{xcolor}

\usepackage[framemethod=default]{mdframed}

\usepackage[most]{tcolorbox}
\usepackage{hyperref}



\definecolor{ocre}{RGB}{243,102,25}


%-------Etapa Box------------
\newmdenv[skipabove=7pt,
skipbelow=7pt,
rightline=false,
leftline=true,
topline=false,
bottomline=false,
backgroundcolor=ocre!10,
linecolor=ocre,
innerleftmargin=5pt,
innerrightmargin=5pt,
innertopmargin=5pt,
innerbottommargin=5pt,
leftmargin=0cm,
rightmargin=0cm,
linewidth=4pt]{eBox}
%------------------------------------------

%-------Hyperref and BookMark-------
\hypersetup{hidelinks,backref=true,pagebackref=true,hyperindex=true,colorlinks=false,breaklinks=true,urlcolor= ocre,bookmarks=true,bookmarksopen=false,pdftitle={Title},pdfauthor={Author}}
\usepackage{bookmark}

\bookmarksetup{
open,
numbered,
addtohook={%
\ifnum\bookmarkget{level}=0 % chapter
\bookmarksetup{bold}%
\fi
\ifnum\bookmarkget{level}=-1 % part
\bookmarksetup{color=ocre,bold}%
\fi
}
}

\renewcommand*{\thechapter}{%
  \texorpdfstring{}{\chaptername\space}\arabic{chapter}%
  \texorpdfstring{}{: }%
}
% Section numbers without prefix or the place for adding a prefix
% "Section".
\renewcommand*{\thesection}{%
  \arabic{chapter}.\arabic{section}%
}
%------------------------------------------


\newtcolorbox[auto counter, number within=section]{etapa}[1][]{
  enhanced,
  attach title to upper={},
  coltitle={ocre},
  fonttitle={\bfseries},
  title={Passo \thetcbcounter:\ },
  sharp corners,
  frame hidden,
  boxrule=0pt,
  borderline west={2pt}{0pt}{ocre},
  colback={ocre!10},
  overlay={
    \node[left,inner sep=6pt,ocre,font=\small] (A) at (interior.east) {$\blacksquare$};},
  #1
}

\begin{document}

\tableofcontents

\chapter{Informações}
\section{Conversa informal}

\begin{etapa}
Texto
\end{etapa}

\end{document}

enter image description here

  • could you change your code so that "Passo 1.1.1" is displayed? – LCarvalho Oct 26 '17 at 19:46
  • @LCarvalho: Why??? What is 1.1.1 supposed to be? – user31729 Oct 26 '17 at 19:46
  • I changed this information in my question – LCarvalho Oct 26 '17 at 19:49
  • @LCarvalho: Question change is not very popular here on TeX.SE, but it is very easy achieved here: number within=section instead of number within=chapter ... – user31729 Oct 26 '17 at 19:49
  • I just realized that I asked the wrong one only when I saw your answer – LCarvalho Oct 26 '17 at 20:10

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.