4

Is there any LaTeX package that can produce tables and figures like the example in the folowing image by default?

wanted

EDIT:

I used tcolorbox but I did not get the result needed as I'm not familiar with its options. here is my code (I found it here)

\newtcolorbox{theorem}[1][]{
breakable,
enhanced,
colback=white,
colframe=black,
top=\baselineskip,
enlarge top by=\topsep,
overlay unbroken and first={
  \node[xshift=100pt,thick,draw=black,fill=white,anchor=west] at (frame.north west) %
  {\refstepcounter{theorem}\strut{\bfseries\theoname~\thetheorem}\if#1\@empty\relax\relax\else~: #1\fi};
  }
}

and this is the result enter image description here

How can I customise it in order to be similar to the above one?

  • 1
    Welcome to TeX.SX! I think you're looking for pgfplots package. – Claudio Fiandrino May 12 '14 at 7:42
  • 1
    'By default' is a bit of a broad term here: as already mentioned, there are packages such as pgfplots that can make plots, but you will have to make changes to get a good reproduction of the example. – Joseph Wright May 12 '14 at 7:45
  • 1
    @user42987: I've likely misunderstood, but after reading: "Is there any package in Latex that can produce table and figure [..]", I think is pretty normal to suggest a package that can draw the figure. Could you be more specific then? – Claudio Fiandrino May 12 '14 at 8:00
  • 1
    Have you tried to use the float environnement? – Romain Picot May 12 '14 at 8:12
  • 1
    You could take a look at the tcolorbox or mdframed packages, combined with the caption package. – Bernard May 12 '14 at 9:01
4

How about this solution using tcolorbox ?

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

\newtcolorbox[auto counter]{myfigure}[2][]{enhanced,center upper,
  colback=white,colbacktitle=black!20!white,coltitle=black,
  arc=0pt,outer arc=0pt,fonttitle=\scshape,lefttitle=2.4cm,
  boxrule=0.3mm,
  overlay={
    \fill[black!20!white] ([xshift=2.2cm,yshift=-0.3mm]title.south west) rectangle (frame.north east);
    \fill[black] ([yshift=-0.3mm]title.south west) rectangle
      node[white] {\sffamily Figure~\thetcbcounter}
      ([xshift=2.2cm]title.north west);
  },title={#2},#1}

\begin{document}

\begin{myfigure}{Prevalence des Prescriptions des Molecules d'Antibiotiques
  les plus Frequntes, par Annee d'Enquete}
\includegraphics[width=10cm]{example-image-a}
\end{myfigure}

\end{document}

enter image description here

If this new figure should contain the chapter number and behave like an 'ordinary' LaTeX figure, use the following modification:

\newtcolorbox[use counter=figure,number within=chapter,
  list inside=lof,list type=figure]{myfigure}[2][]{enhanced,center upper,
  colback=white,colbacktitle=black!20!white,coltitle=black,
  arc=0pt,outer arc=0pt,fonttitle=\scshape,lefttitle=2.4cm,
  boxrule=0.3mm,
  overlay={
    \fill[black!20!white] ([xshift=2.2cm,yshift=-0.3mm]title.south west) rectangle (frame.north east);
    \fill[black] ([yshift=-0.3mm]title.south west) rectangle
      node[white] {\sffamily Figure~\thetcbcounter}
      ([xshift=2.2cm]title.north west);
  },title={#2},#1}

Then, the new figure will be listed inside the list of figures using

\listoffigures
  • Thak you for your help, this is what I expected, but I got an error when compiling: Unknown option many for package tcolorbox. \ProcessOptions* – user42987 May 12 '14 at 17:15
  • I will try to update packages and tell you – user42987 May 12 '14 at 17:35
  • 1
    I quite sure that you have an old version of tcolorbox. The current version is 3.00. After an update, it should work. – Thomas F. Sturm May 12 '14 at 17:35
  • 1
    @user42987 I'm glad that I could help. Maybe, it's also useful to know for you that you can make the figure floatable by adding the option float to the keylist or - more flexible - individually by using \begin{myfigure}[float]{... – Thomas F. Sturm May 13 '14 at 8:28
  • 1
    @user42987 See my updated answer. – Thomas F. Sturm May 13 '14 at 13:10
2

If you only want to draw the graph, I suggest you have a look at a drawing program using LaTeX or producing LaTeX-code.

One program is Ipe v 7. Another program is Nicola Talbot’s jpgfdraw.

Ipe is using LaTeX to produced PDF-files you may include in the main document.

  • Thak you for your help, I'm not looking for producing graphics, I Just want to produce a box (similar to the one above) around my included plots that contain the number of the figure and the caption. – user42987 May 12 '14 at 8:12
  • 1
    @user42987 Then just put the picture in an ‘fbox’. – Sveinung May 12 '14 at 8:19
  • 1
    @user42987 You may also try ‘framebox’, forkosh.com/latex/ltx-237.html – Sveinung May 12 '14 at 8:23

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.