4

This question already has an answer here:

I try to change font familly in my tcolorbox to have similar font than the font for source code in stackoverflow, without success.

The height of line is also not correct, there is a difference between line with box and line without box, is there a way to define automatically the correct height of the box to eliminate this effect ?

enter image description here

The code for box is

   \makeatletter
    \newtcbox{\keywordmin}{on line, fontupper=\scriptsize\texttt, boxrule=0.5pt,arc=2pt,coltext=tangoBlack1,colback=tangoGrey1,colframe=tangoGrey1,boxsep=0pt,left=2pt,right=2pt,top=2pt,bottom=2pt}
    \makeatother

Here the complete MWE

% !TEX encoding =  UTF-8 Unicode
% -*- program: xelatex -*-
\documentclass[a4paper, 11pt,twoside, openright]{memoir}
\usepackage{mwe} % just for dummy images
\usepackage{amssymb}
\usepackage{amsmath,mathtools}
\usepackage{amstext}    % defines the \text command, needed here
\usepackage{array}
\usepackage{tcolorbox} 

\definecolor{tangoBlack1}{RGB}{0,0,0}
\definecolor{tangoGrey1}{RGB}{136,138,133}

\usepackage{sepfootnotes}
\newfootnotes{A}

\footmarkstyle{[#1]~}
\setlength{\footmarkwidth}{-1sp}
\setlength{\footmarksep}{0pt}
\setlength{\footparindent}{0pt}
\renewcommand{\foottextfont}{\scriptsize\raggedright}

\makeatletter
\newtcbox{\keywordmin}{on line, fontupper=\scriptsize\texttt, boxrule=0.5pt,arc=2pt,coltext=tangoBlack1,colback=tangoGrey1,colframe=tangoGrey1,boxsep=0pt,left=2pt,right=2pt,top=2pt,bottom=2pt}
\makeatother

\begin{document}

\Anotecontent{code_note}{This is a technical note with \keywordmin{Code} tag used to describe \keywordmin{keyword} in source code. This is a technical note with \keywordmin{Code} tag used to describe \keywordmin{keyword} in source code. I want to add some blablabla on the same line..I want to add some blablabla on the same line..I want to add some blablabla on the same line..I want to add some blablabla on the same line..  I want to add some blablabla on the same line..I want to add some blablabla on the same line.. }

This is a message which need a footnotes \Anote{code_note}.

\end{document}

Update 1 :

I upgrade the question using first answer based on @harish-kumar answer and answer of this question to better explain my need.

If i augment the size of extrude (like extrude by=3pt or extrude by=4pt) to construct a more fancy box, the extrud "eat" other word around. Is there a way with tcolorbox to maintain a correct space (1pt) betwen colored box and the word around ?

enter image description here

marked as duplicate by Ignasi, Paul Gessler, barbara beeton, Symbol 1, user31729 Apr 6 '15 at 16:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

8

You can use shrink tight,extrude by=2pt in this way

\newtcbox{\keywordmin}{on line, fontupper=\scriptsize\ttfamily, boxrule=0.5pt,arc=2pt,coltext=tangoBlack1,colback=tangoGrey1,colframe=tangoGrey1, boxsep=0pt,shrink tight,extrude by=2pt}

Here shrink tight makes the total colored box to be shrunk to the dimensions of the upper part while extrude by = 2pt makes the colored box to be extruded by 2pt to all sides. The inner width and the bounding box is kept unchanged.

Also, you should use fontupper=\scriptsize\ttfamily instead of \texttt.

Code:

% !TEX encoding =  UTF-8 Unicode
% -*- program: xelatex -*-
\documentclass[a4paper, 11pt,twoside, openright]{memoir}
\usepackage{mwe} % just for dummy images
\usepackage{amssymb}
\usepackage{amsmath,mathtools}
\usepackage{amstext}    % defines the \text command, needed here
\usepackage{array}
\usepackage{tcolorbox}

\definecolor{tangoBlack1}{RGB}{0,0,0}
\definecolor{tangoGrey1}{RGB}{136,138,133}

\usepackage{sepfootnotes}
\newfootnotes{A}

\footmarkstyle{[#1]~}
\setlength{\footmarkwidth}{-1sp}
\setlength{\footmarksep}{0pt}
\setlength{\footparindent}{0pt}
\renewcommand{\foottextfont}{\scriptsize\raggedright}

\makeatletter
\newtcbox{\keywordmin}{on line, fontupper=\scriptsize\ttfamily, boxrule=0.5pt,arc=2pt,coltext=tangoBlack1,colback=tangoGrey1,colframe=tangoGrey1, boxsep=0pt,shrink tight,extrude by=2pt}
\makeatother

\begin{document}

\Anotecontent{code_note}{This is a technical note with \keywordmin{Code} tag used to describe \keywordmin{keyword} in source code. This is a technical note with \keywordmin{Code} tag used to describe \keywordmin{keyword} in source code. I want to add some blablabla on the same line..I want to add some blablabla on the same line..I want to add some blablabla on the same line..I want to add some blablabla on the same line..  I want to add some blablabla on the same line..I want to add some blablabla on the same line.. }

This is a message which need a footnotes \Anote{code_note}.

\end{document}

enter image description here

  • Thnaks for answer, is it possible to add some free space around the box, because if i extrude more (like 3pt), the box color other word around :/ ? (i update my question) – reyman64 Apr 7 '15 at 12:18
  • @reyman64 If you do that the spacing will be uneven as your earlier case. You have to maintain optimum space yourself. There is also extrude left, extrude top etc if you want to adjust all sides independently. Do something like extrude top=3pt,extrude bottom=3pt,extrude right=2pt, extrude left=2pt – user11232 Apr 7 '15 at 12:35

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