3

I created my own envorinment for placing quotes or something important in my text. (it is simply a \node inside tikz) However, when I set the \textwidth of the nodeto \linewidth and set an inner sep the right border is outside my margins. When I use a smaller textwidth like .9\linewidth it seems to be okay. Smaller textwidths also work. I want that the border are excatly at the linewidth:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{environ}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{shapes.geometric}
\usepackage{lipsum}
\NewEnviron{bquote}{%
\par%
\vspace{.5cm}
\noindent% 
\centering
\begin{tikzpicture}[every node/.style={align=justify}]%   %%Linewidth default bei 7pt
\node[text width=.7\linewidth,font=\normalsize, scale=1, draw=none,inner sep=20](q){\BODY};%
\draw[fill=red] (q.center) circle (1cm) node {OKAY};
\draw[semithick,line width=.4pt,overlay,black] ($(q.north west) + (15pt,0)$)--(q.north west)--(q.south west)-- ($(q.south west) + (15pt,0)$);%
\draw[semithick, line width=.4pt,overlay,black] ($(q.north east) - (15pt,0)$) --(q.north east)  -- (q.south east)--($(q.south east)- (15pt,0)$) ;% 
\end{tikzpicture}%
\par%
\vspace{.35cm}
}%
\title{ForumMWE}

\begin{document}
\maketitle
\section{Introduction}
\lipsum[4]
\begin{bquote}
\lipsum[4]
\end{bquote}
\noindent\lipsum[4]
\end{document}

This result in:

enter image description here

Changing this

\node[text width=.7\linewidth,font=\normalsize, scale=1, draw=none,inner sep=20](q){\BODY};%

to this

\node[text width=1\linewidth,font=\normalsize, scale=1, draw=none,inner sep=20](q){\BODY};%

result in:

enter image description here

3

You need to compute the line width so to remove the space for the braces:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{environ}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{shapes.geometric}
\usepackage{lipsum}

\NewEnviron{bquote}{%
  \par
  \addvspace{\topsep}
  \centering
  \begin{tikzpicture}[baseline,every node/.style={align=justify}]%   %%Linewidth default bei 7pt
  \node[
    text width=\linewidth-40pt,
    font=\normalsize,
    scale=1,
    draw=none,
    inner sep=20
  ](q){\BODY};
  \draw[fill=red] (q.center) circle (1cm) node {OKAY};
  \draw[semithick,line width=.4pt,overlay,black]
    ($(q.north west) + (15pt,0)$)--(q.north west)--(q.south west)
     -- ($(q.south west) + (15pt,0)$);
  \draw[semithick, line width=.4pt,overlay,black]
    ($(q.north east) - (15pt,0)$) --(q.north east)  -- (q.south east)
     --($(q.south east)- (15pt,0)$) ;
  \end{tikzpicture}%
  \par
  \addvspace{\topsep}
}

\title{ForumMWE}
\author{SRel}

\begin{document}
\maketitle
\section{Introduction}
\lipsum[4]
\begin{bquote}
\lipsum[4]
\end{bquote}
\noindent\lipsum[4]
\end{document}

enter image description here

| improve this answer | |
  • is text width=\linewidth-40 not enough ? – nidhin Aug 13 '19 at 15:27
  • @nidhin Apparently it is. ;-) – egreg Aug 13 '19 at 15:30

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.