2

In order to insert a logo picture in my sheet, I want to use the tcolorbox, but I don't know how to create a new environment to include it inside a node before the \begin{document}.

Here's my code that can be compile correctly with xelatex

   \documentclass[12pt,a4paper]{report} \usepackage[top=13cm,bottom=1.5cm,right=1.5cm,left=2.5cm]{geometry} \usepackage{eso-pic} 
\usepackage{tikz,varwidth,multicol}
\usepackage[most]{tcolorbox} 
\pagestyle{empty} 
\definecolor{fff}{RGB}{249, 212, 6} 
\definecolor{vvv}{RGB}{47, 138, 58}
\definecolor{ccc}{RGB}{255,140,0} 
\definecolor{ggg}{RGB}{250,250,250} 
\tikzset{a/.style={anchor=west,line width=1.5pt,font=\bfseries\Large,rounded corners=2mm,draw=black,text=black,inner xsep=5mm,minimum height=1.5cm,rotate=-90}} 
\usetikzlibrary{calc}

\newcommand{\image}[3][1]{\includegraphics[width=#1\textwidth,height=#2\textheight,keepaspectratio]{#3}}
\renewcommand{\labelenumi}{ 
\begin{tikzpicture}[baseline=(1.base)] \node[circle,fill=fff,text=black,font=\bfseries,minimum size=5mm,inner sep=0mm](1){\arabic{enumi}}; 
\end{tikzpicture} } 
\AddToShipoutPicture{ 
\begin{tikzpicture}[remember picture,overlay]
\node [fill=fff,minimum width=\paperheight,minimum height=2cm,anchor=south east,rotate=-90](0)at ([xshift=0cm]current page.south west){}; 
\node[a](2)at($(0.west)!.9!(0.east)$){\image[0.1]{0.9}{./images/logo}
}; 
 
\end{tikzpicture} }
%---- define the border of exercice ------%
\newtcolorbox[auto counter]{exo}{breakable,top=1cm,title={Exercice \thetcbcounter},enhanced,before skip=5mm,after skip=5mm,boxsep=3mm,coltitle=black,attach boxed title to top left={xshift=5mm,yshift=-\tcboxedtitleheight},boxrule=.5pt,boxed title style={interior empty,frame code={ \fill([xshift=1mm]frame.north east)arc(180:0:1mm)([xshift=-1mm]frame.north west)arc(0:180:1mm); \path[right color=fff,left color=fff,middle color=fff!60] ([shift={(-.2,.1)}]frame.north west)--([shift={(.2,.1)}]frame.north east)[rounded corners=1mm]--([xshift=.1cm]frame.north east)--(frame.south east)--(frame.south west)--([xshift=-.1cm]frame.north west)[sharp corners]--cycle; } }}\usepackage{polyglossia}
\setmainlanguage{french} 
\newfontfamily\frenchfont{Times New Roman}
\begin{document}
\vspace{15cm}
\begin{exo} 
Recopier et compléter les égalités suivantes:
\begin{enumerate} 
\item $7\times15-\cdots )=70$ 
\item $5\times13-5\times\cdots =50$
\item $17\times(3.4+\cdots)=170$
\item $23\times2.3+23\times\cdots=230$
\end{enumerate}
\begin{center}
\begin{tcolorbox}[width=0.3\textwidth,height=0.13\textheight,
    enhanced,clip upper,%<------------
    colframe=red,colback=gray,boxrule=1pt,arc=10pt,
    boxsep=0pt,left=0pt,right=0pt,top=0pt,bottom=0pt]
     \includegraphics[width=\textwidth, height=0.13\textheight]{./images/logo}
\end{tcolorbox} \end{center}
\end{exo} 

\end{document}

when I compile this code, I get the following document fix fill size image in margin Ccan anyone help remove the badding (the white space) of the picture in the left margin? It would be very appreciated.

5
  • Mmm… It's not quite clear to me. Do you really wishing to insert a \tcolorbox with the logo in the margin, or do you think a \tcolorbox is necessary to insert the logo?
    – Bernard
    Aug 18, 2020 at 23:26
  • Or is your complaint that the image you've inserted has a white background instead of yellow?
    – Teepeemm
    Aug 18, 2020 at 23:31
  • just, i want to remove the white space in the image, i can do this inside the document environment but in the margin i don't khnow how isert it ?
    – moradov
    Aug 18, 2020 at 23:32
  • I don't see how you remove white space in the image inside the document. I would assume that you have a white background because imges/logo has a white background. Can you make the background transparent?
    – Teepeemm
    Aug 19, 2020 at 0:07
  • I want to make the image with full size in border , you can see the difference between the two images the image that i had insert using the tcolorbox has no badding but that i insert with the newcommand in the margin has a badding (sapce between the image and border)
    – moradov
    Aug 19, 2020 at 2:30

1 Answer 1

3

I think you want something like this. I've defined a myboxedlogo command with three parameters: Optional tcolorbox parameters, includegraphics parameters and figure name. This command is used to include the logo in main page and on left margin.

By the way, instead of a tcolorbox I've used a tcbincludegraphics command.

\documentclass[12pt,a4paper]{report} \usepackage[top=13cm,bottom=1.5cm,right=1.5cm,left=2.5cm]{geometry} 
\usepackage{eso-pic} 
\usepackage{tikz,varwidth,multicol}
\usepackage[most]{tcolorbox} 
\pagestyle{empty} 
\definecolor{fff}{RGB}{249, 212, 6} 
\definecolor{vvv}{RGB}{47, 138, 58}
\definecolor{ccc}{RGB}{255,140,0} 
\definecolor{ggg}{RGB}{250,250,250} 

\tikzset{a/.style={inner sep=0pt}} 
\usetikzlibrary{calc}

\newcommand{\image}[3][1]{\includegraphics[width=#1\textwidth,height=#2\textheight,keepaspectratio]{#3}}

\renewcommand{\labelenumi}{ 
\begin{tikzpicture}[baseline=(1.base)] \node[circle,fill=fff,text=black,font=\bfseries,minimum size=5mm,inner sep=0mm](1){\arabic{enumi}}; 
\end{tikzpicture} } 

\newcommand{\myboxedlogo}[3][]{%
\tcbincludegraphics[hbox, size=tight, colframe=red, boxrule=1pt, arc=10pt, auto outer arc, clip upper, #1, graphics options={#2}]{#3}
}

\AddToShipoutPicture{ 
\begin{tikzpicture}[remember picture,overlay]
\node [fill=fff,minimum width=\paperheight,minimum height=2cm,anchor=south east,rotate=-90](0)at ([xshift=0cm]current page.south west){}; 
\node[inner sep=0pt](2)at($(0.west)!.9!(0.east)$){\myboxedlogo{width=.1\textwidth, height=0.9\textheight, keepaspectratio, angle=-90}{example-image-a}};
\end{tikzpicture} }

%---- define the border of exercice ------%
\newtcolorbox[auto counter]{exo}{breakable,top=1cm,title={Exercice \thetcbcounter},enhanced,before skip=5mm,after skip=5mm,boxsep=3mm,coltitle=black,attach boxed title to top left={xshift=5mm,yshift=-\tcboxedtitleheight},boxrule=.5pt,boxed title style={interior empty,frame code={ \fill([xshift=1mm]frame.north east)arc(180:0:1mm)([xshift=-1mm]frame.north west)arc(0:180:1mm); \path[right color=fff,left color=fff,middle color=fff!60] ([shift={(-.2,.1)}]frame.north west)--([shift={(.2,.1)}]frame.north east)[rounded corners=1mm]--([xshift=.1cm]frame.north east)--(frame.south east)--(frame.south west)--([xshift=-.1cm]frame.north west)[sharp corners]--cycle; } }}\usepackage{polyglossia}
\setmainlanguage{french} 
\newfontfamily\frenchfont{Times New Roman}
\begin{document}
\vspace{15cm}
\begin{exo} 
Recopier et compléter les égalités suivantes:
\begin{enumerate} 
\item $7\times15-\cdots )=70$ 
\item $5\times13-5\times\cdots =50$
\item $17\times(3.4+\cdots)=170$
\item $23\times2.3+23\times\cdots=230$
\end{enumerate}
\begin{center}
%\begin{tcolorbox}[width=0.3\textwidth,height=0.13\textheight,
%    enhanced,clip upper,%<------------
%    colframe=red,colback=gray,boxrule=1pt,arc=10pt,
%    boxsep=0pt,left=0pt,right=0pt,top=0pt,bottom=0pt]
%     \includegraphics[width=\textwidth, height=0.13\textheight]{example-image-a}
%\end{tcolorbox} 
\myboxedlogo[colframe=blue]{width=.3\textwidth, height=0.13\textheight}{example-image-a}
\end{center}
\end{exo} 

\end{document}

enter image description here

1
  • Thanks for your help in solving this problem.
    – moradov
    Aug 19, 2020 at 11:36

You must log in to answer this question.

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