4

I want make block in my document like javadoc method description (see figure)Here are what I want get

I have wrotten a macro:

\def\makemybox{%
\noindent%
\fcolorbox[HTML]{9EADC0}[HTML]{F9F9F9}{%
    \makebox[\textwidth]{%
        \vbox{%
            \noindent%
            \fcolorbox[HTML]{9EADC0}[HTML]{DEE3E9}{%
                \makebox[\textwidth][l]{\textbf{Method name}}       
            }\par%
            \noindent%
            \makebox[\textwidth][l]{Method description}     
        }
    }
}}

but I get wrong boxes. See figureThis is what I get

How I can fix my macro? I tried to set \fboxsep but I had no result.

5

With tcolorbox it's easy.

MWE:

\documentclass{article}
\usepackage[most]{tcolorbox}

\definecolor{blue1}{HTML}{DEE3E9}
\definecolor{blue2}{HTML}{F9F9F9}
\definecolor{blue3}{HTML}{9EADC0}

\newtcolorbox{mybox}[1]{%
      arc=0pt,
      outer arc=0pt,
      top=0pt,
      bottom=0pt,
      left=0pt,
      right=0pt,
      boxrule=0.4pt,
      breakable,
      colback=blue2,
      colframe=blue3,
      colbacktitle=blue1,
      coltitle=black,
      fonttitle=\bfseries,
      title=#1
}

\begin{document}

\begin{mybox}{Method name}
asdfgfgbaaf
\end{mybox}

\end{document} 

enter image description here

1

With mdframed:

\documentclass{article}
\usepackage[framemethod=TikZ]{mdframed}

\definecolor{blue1}{HTML}{DEE3E9}
\definecolor{blue2}{HTML}{F9F9F9}
\definecolor{blue3}{HTML}{9EADC0}

\mdfdefinestyle{mybox}%
{leftmargin=0pt, rightmargin=2pt,innerleftmargin=5pt,
frametitlerule=true,frametitlerulecolor=blue3,
frametitlebackgroundcolor=blue1,
%frametitlerulewidth=0.4pt,
%linewidth=0.5pt,
backgroundcolor=blue2,
linecolor=blue3,
frametitlefont={\bfseries\sffamily\color{black}},
}

\newmdenv[style=mybox]{mybox}

\begin{document}

\begin{mybox}[frametitle={Method name}]
asdfgfgbaaf
\end{mybox}

\end{document}

enter image description here

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.