2

Is it possible for multiple mdframed blocks to have a contiguous background and border if they are next to each other? Here's an example:

These blocks are one after the other in code. enter image description here

They appear with space between because I want isolated blocks to have some spacing with the rest of the text. What I would like is that if they're next to each other (and are of the same style), the background and border would extend between them like this: (edited on Photoshop) enter image description here

This is the code I have right now

\documentclass[11pt, a4paper]{article}
\usepackage[utf8]{inputenc}

\usepackage{amsthm}
\usepackage{mdframed}
\usepackage{xcolor}

\newtheoremstyle{definition-style} 
{}               
{}               
{}                   
{}                   
{\bf\sffamily}               
{.}                 
{.5em}               
{\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}}

\mdfdefinestyle{ndef-frame}{
linewidth=1pt, %
linecolor= gray, % 
backgroundcolor= gray!5,
topline=false, %
bottomline=false, %
rightline=false,%
leftmargin=0pt, %
innerleftmargin=1em, %
innerrightmargin=1em, 
rightmargin=0pt, % 
innertopmargin=1.5em,%
innerbottommargin=1em, % 
splittopskip=\topskip, %
%splitbottomskip=\topskip, %
}% 

\surroundwithmdframed[style=ndef-frame]{ndef}

\theoremstyle{definition-style}
\newtheorem{ndef}{Definición}[section]

\begin{document}

\begin{ndef}[Name] Text
\end{ndef}

\begin{ndef}[Name] Text
\end{ndef}

\end{document}
  • 1
    Welcome. Please provide a full compatible minimal working example(MWE): tex.meta.stackexchange.com/questions/228/… – Bobyandbob Apr 22 '17 at 19:25
  • @Bobyandbob Added code – José María Apr 22 '17 at 19:29
  • @JoséMaría: Your code is a fragment and not compilable. – user31729 Apr 22 '17 at 19:49
  • 2
    @ChristianHupfer Now it's compilable – José María Apr 22 '17 at 20:07
  • 1
    Just put them in one block and include some space where you want it? Or use a nested environment to manage the space automatically. – cfr Apr 22 '17 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.