TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to build a Dungeons and Dragons style LaTeX-Template and would like to recreate a certain box-style as seen here:

box

Using tikz I managed to recreate the rough shape but I don't have any idea how to...

  • scale the box vertically so it fits the text
  • put the text into the box which automatically linebreaks to fit the right margin

Any help would be very appreciated :-).

MWE:

\documentclass[10pt,twoside]{article}
\usepackage{multicol}
\usepackage{tikz}   %for quotebox
    \let\svtikzpicture\tikzpicture              %remove left indent for tikz picture
    \def\tikzpicture{\noindent\svtikzpicture}   %remove left indent for tikz picture

\begin{document}
\begin{multicols}{2}

\begin{tikzpicture}
\path [fill=gray] (0,0) rectangle (\linewidth,10em);
\draw [red, thick] (0,0) -- (0,10em);
    \draw [red,fill] (0,0) circle [radius=0.05];
    \draw [red,fill] (0,10em) circle [radius=0.05];
\draw [red,thick] (\linewidth,0) -- (\linewidth,10em);
    \draw [red, fill] (\linewidth,0) circle [radius=0.05];
    \draw [red, fill] (\linewidth,10em) circle [radius=0.05];
\node at (1em,5em) {text};
\end{tikzpicture}
\end{multicols}
\end{document}
share|improve this question
    
You can have a look on tcolorbox, which is a tikz package and allows nice boxes with additioins – Christian Hupfer Mar 1 at 16:04
up vote 6 down vote accepted

I had the same idea as Christian, but as my implementation looks a bit more like the original, I'm posting another answer.

\documentclass{article}
\usepackage[most]{tcolorbox}
\definecolor{background}{HTML}{FCF9EE}
\definecolor{linecolor}{HTML}{581810}

\begin{document}
\begin{tcolorbox}[
    enhanced,
    boxsep=0.25ex,
    arc=0mm,
    borderline west={1pt}{-0.5pt}{linecolor},
    borderline east={1pt}{-0.5pt}{linecolor},
    colback=background,
    colframe=background,
    overlay={
          \foreach \n in {north east,north west,south east,south west}
          {\draw [linecolor, fill=linecolor] (frame.\n) circle (2pt); }; }]
\begin{description}
    \item[Dungeon Master (DM):] OK, one at a time. Phillip, you are looking at the gargoyles?
    \item[Phillip:] Yeah. Is there any hint they might be creatures and not     decorations?
    \item[DM:] Make an Intelligence check.
    \item[Phillip:] Does my Investigation skill apply?
    \item[DM:] Sure!
    \item[Phillip (rolling a d20):] Ugh. Seven.
    \item[DM:] They look like decorations to you. And Amy, Riva is checking out the drawbridge?
\end{description}
\end{tcolorbox}
\end{document}

tcolorbox


EDIT:

As you probably want to use this box multiple times in your document it makes sense to define a new environment based on tcolorbox like this:

\newtcolorbox{dungeonbox}{enhanced,
    boxsep=0.25ex,
    arc=0mm,
    borderline west={1pt}{-0.5pt}{linecolor},
    borderline east={1pt}{-0.5pt}{linecolor},
    colback=background,
    colframe=background,
    overlay={
      \foreach \n in {north east,north west,south east,south west}
        {%
        \draw [linecolor, fill=linecolor] (frame.\n) circle (2pt);
        };
    }
}

You can then easily use it like this:

\begin{dungeonbox}
...
\end{dungeonbox}
share|improve this answer
    
That's better and easier to use than mine! (+1) – Christian Hupfer Mar 1 at 16:47
    
Thanks a lot, that looks and works great :-) ! – Cathode Mar 1 at 18:35
    
@Cathode You are welcome. Please have a look at my edit for an additional tip. – Benjamin Mar 1 at 18:44
    
Thanks, that makes using it as a template even easier :-). – Cathode Mar 1 at 22:02

Here is tcolorbox with overlay additions etc. It's breakable.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage[most]{tcolorbox}
\usepackage{blindtext}

\newlength{\vertlinewidth}
\setlength{\vertlinewidth}{1pt}
\newlength{\vertlineoffset}
\setlength{\vertlineoffset}{-5pt}
\newlength{\circleradius}
\setlength{\circleradius}{3pt}
\newlength{\circleoffset}
\setlength{\circleoffset}{0pt}


\definecolor{dungeoncolor}{RGB}{255,0,0}

\newtcolorbox{dungeonbox}[1][]{enhanced jigsaw,frame hidden,boxrule=0pt,
  breakable,
  sharp corners,
  drop lifted shadow,
  colback=white!90!black,
  borderline vertical={\vertlinewidth}{\vertlineoffset}{dungeoncolor},
  overlay={opacity=1.0,
    \node (A) at (frame.north west) {};\draw[fill,dungeoncolor] ($(A) + (\vertlineoffset-\vertlinewidth+0.5\circleradius,\circleoffset+\circleradius)$) circle (\circleradius);
    \node (B) at (frame.south west) {};\draw[fill,dungeoncolor] ($(B) + (\vertlineoffset-\vertlinewidth+0.5\circleradius,-\circleoffset-\circleradius)$) circle (\circleradius);
    \node (C) at (frame.south east) {};\draw[fill,dungeoncolor] ($(C) + (-\vertlineoffset+\vertlinewidth-0.5\circleradius,-\circleoffset-\circleradius)$) circle (\circleradius);
    \node (D) at (frame.north east) {};\draw[fill,dungeoncolor] ($(D) + (-\vertlineoffset+\vertlinewidth-0.5\circleradius,\circleoffset+\circleradius)$) circle (\circleradius);},
  #1
}

\begin{document}

\begin{dungeonbox}
\blindtext[10]
\end{dungeonbox}
\end{document}

enter image description here

share|improve this answer
    
Thank you :-) ! – Cathode Mar 1 at 22:03

You can fill in the text at the same instant when you make the rectangle. Use the fact that nodes are by default rectangle shaped(?). Tikz auto magically sizes the rectangle. Since you seem to want only vertical resising, specify the horizontal size of the box. For that, you can specify the width of the text so that Tikz knows where to break long sentences (text width =). There is probably an easy way to draw the red lines and the circles automatically by specifying node /.style, but I do not know how to do it. I used the corners of the rectangle node by using the anchors such as north east etc to position the red lines and circles.

\documentclass[10pt,twoside]{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
% make a node (rectangle)
% filled with gray
% occuplying half the current \textwidth
% name it mybox for reffering later
% add the text to it right away so that tikz can 
% calculate how big the box should be
\node [fill=gray, text width=0.5\textwidth] (0,0) (mybox)
{%
\begin{description}
\item [dungeon master] says Hi.
\item [player one] says Hi.
\item [player two] says Hi.
\item [player three] says Hi.
\end{description}
};
%use the above node's anchors to position the red lines and circles
\draw [red, thick] (mybox.south west) -- (mybox.north west);
    \draw [red,fill] (mybox.south west) circle [radius=0.05];
    \draw [red,fill] (mybox.north west) circle [radius=0.05];
\draw [red,thick] (mybox.south east) -- (mybox.north east);
    \draw [red, fill] (mybox.south east) circle [radius=0.05];
    \draw [red, fill] (mybox.north east) circle [radius=0.05];
\end{tikzpicture}
\end{document}

DandD

share|improve this answer
    
Thanks! Although the tcolorbox variant seems easier knowing about the possibility to define coordinates via cardinal directions is still helpful :-)! – Cathode Mar 1 at 22:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.