6

Wanting to highlight parts of my text, intended to be read at second reading, by an inexpensive method in packages, I want to set up an environment that would put points at the beginning and end of the line, preferably at the margins of the environment. I obviously want to be able to include in this environment to create all kinds of texts or mathematical objects, like figures, theorems, footnotes ... in particular boxes produced with tcolorbox and some other environments... so the solution must be not based on any package I think, and especially not using tcolorbox or another package producing boxes !

I give an example of what I want to create, which I made by adding \dotfill, at the beginning and at the end of the text, while adding points at the beginning and end of the line thanks to \hfill. enter image description here I actually want to create a, say \vdotfill{text}, environment, based on the idea of the \dotvfill command, included in the answer of the following question vertical dotfill and then put my text between \dotfill up and down, and between some \vdotfill between right and left. Any ideas ?

2 Answers 2

8

Yes, do not reinvent the wheel:

mwe

\documentclass{article}
\usepackage{lipsum}
\usepackage[most]{tcolorbox}
\newtcolorbox{dottedenvironment}{enhanced,
boxrule=0pt,boxsep=1em,colback=white, arc=3mm, frame hidden,
borderline={1pt}{2pt}{red!30!black,dotted}}
\begin{document}

\begin{dottedenvironment}
\lipsum[2]  
\end{dottedenvironment}

\end{document}

Edit: As stated in the comments, It seems a requeriment that boxes should be breakable even nested. I do not know an automatic approach and I think that is not a good idea (*), but manually you can break a nested tcolorbox

(*) Note that enforce breakable option is a bit insane.

mwe2

\documentclass{article}
\usepackage[paperwidth=8cm,paperheight=8cm]{geometry}
\usepackage{ltablex}
\usepackage{lipsum}
\usepackage[most]{tcolorbox}
\newtcolorbox{dottedenvironment}{enhanced,enforce breakable, boxrule=0pt,boxsep=1em,colback=white, arc=3mm, frame hidden,
borderline={1pt}{2pt}{red!30!black,dotted}}
\def\dummytext{The key message for success is to keep it simple. }
\def\moretext{\dummytext\dummytext\par}
\begin{document}
\begin{dottedenvironment}
\moretext
\begin{dottedenvironment}
\dummytext
\tcbbreak
\moretext\end{dottedenvironment}
\tcbbreak
\end{dottedenvironment}
\end{document}
12
  • Sorry but your answer is not useful for complicated objects in my text, like figures, and it's known that tcolorbox refuses the floats... I edit my question to be more precise. Thank you Commented Apr 29, 2018 at 21:32
  • 1
    @FaouziBellalouna I know that tcolorbox refuses a floats inside it (it have no any sense do that) but a floats do not refuse include inside a tcolorbox (or two, or more) with figures, a tabular, or whatever you want, so ... where is the problem?
    – Fran
    Commented Apr 29, 2018 at 22:01
  • Moreover, tcolorbox could be itself a float object (page 76 of manual).
    – Fran
    Commented Apr 29, 2018 at 22:08
  • Recall that my aim was to highlight some parts of my text, which can contain several mathematical objects, like figures, theorems, footnotes ... in particular boxes produced with tcolorbox and some other environments, like I've precized. There's several problems if we want to insert float in tcolorboxes... I'll edit my question another time to precize more. Thanks Commented Apr 30, 2018 at 4:24
  • @FaouziBellalouna You should maybe take a minute and try to think about why floats cannot be inside a tcolorbox. Commented Apr 30, 2018 at 6:06
2

ConTeXt can do this easily using textbackground. You can also include floats (which will not be surrounded by dots because they could appear elsewhere).

\startuseMPgraphic{dottedframe}
begingroup;
  for i=1 upto nofmultipars :
    draw ( llcorner multipars[i]
      -- lrcorner multipars[i]
      -- urcorner multipars[i]
      -- ulcorner multipars[i]
      -- cycle )
      enlarged (EmWidth,EmWidth)
      dashed withdots ;
  endfor ;
endgroup;
\stopuseMPgraphic

\definetextbackground
  [DottedFrame]
  [mp=dottedframe,
   location=paragraph,
   before={\blank[2*big]}]

\starttext

\starttextbackground[DottedFrame]
Text and/or environments and/or equations

Text and/or environments and/or equations

Text and/or environments and/or equations

\startplacefigure[location=here,title={The famous Dutch cow}]
  \externalfigure[cow]
\stopplacefigure

Text and/or environments and/or equations

Text and/or environments and/or equations

Text and/or environments and/or equations
\stoptextbackground

\stoptext

enter image description here

3
  • Thanks for answer, but I've never used ConText. Culd you precize your answer by including a MWE what I can compile, with xelatex, preferably. Thank you Commented Apr 30, 2018 at 6:52
  • @FaouziBellalouna The code in my answer is a MWE. You have to typeset with context which uses LuaTeX under the hood, rather than with [pdf|lua|xe]latex. Commented Apr 30, 2018 at 9:32
  • Thanks but I don't have any idea about LuaTeX, and I use only XeLaTeX. Thanks Commented Apr 30, 2018 at 9:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .