2

Firstly, I would like to say my 'problem' is not primordial nor important. Just the fact that I see it and I can't get it out of my mind... Like a bit of chalk on a board, not important but bothersome.

two annotations with mdframed and then minipage for the two sections

As we can see, these ones are beautiful. But the 'size' (\fontsize here) of the icons are manually written, 20pt here.

So I would like to know if there's a way to do it without the manual font size configuration.

The perfect thing would be if they takes \linewidth (but I'm unsure about the small ones like the exclamation on my example)... Maybe something like \renewcommand{\fontsize}{\the\linewidth} and then write them with \textsf{•} for them to have the same width.

The same picture with comments just in case it could help: Same picture with comments

I saw this post. I just don't know how to adapt it to the icons of FontAwesome... Considering it is a font and not a picture.

Here's the code of this portion:

% Boxes
%
% \annotation
%   {color}
%   {icon}
%   {text}
\newcommand\annotation[3]
{
\begin{mdframed}[
    innerlinewidth    = 2pt   ,
    roundcorner       = 10pt  ,
    innerlinewidth    = 0pt   ,
    middlelinewidth   = 0pt   ,
    outerlinewidth    = 0pt   ,
    innerleftmargin   = 10pt  ,
    innerrightmargin  = 10pt  ,
    innertopmargin    = 10pt  ,
    innerbottommargin = 10pt  ,
    leftmargin        = 0.5cm ,
    rightmargin       = 0.5cm ,
    skipabove         = 0.5cm ,
    skipbelow         = 0.1cm ,
    backgroundcolor   = #1!10
    ]
    \begin{minipage}{0.075\linewidth}
        \begin{center}
            \textcolor{#1}{\fontsize{20pt}{20pt}\selectfont\faIcon{#2}}
        \end{center}
    \end{minipage}
    \begin{minipage}{0.9\linewidth}
        \textit{\color{#1!70}#3}
    \end{minipage}
\end{mdframed}
}

Here's a sample code for you to work on it:

\documentclass{report}
\usepackage[framemethod=tikz]{mdframed} % https://www.ctan.org/pkg/mdframed

% color -> color https://www.ctan.org/pkg/color % tikzpagenodes -> draw figures https://www.ctan.org/pkg/tikzpagenodes % fontawesome5 -> icons https://www.ctan.org/pkg/fontawesome5 \usepackage{color, tikzpagenodes, fontawesome5}

% Defines the colors \definecolor{theme}{HTML}{438DCC} \definecolor{internalLink}{HTML}{707070}

% Boxes % % \annotation % {color} % {icon} % {text} \newcommand\annotation[3] { \begin{mdframed}[ innerlinewidth = 2pt , roundcorner = 10pt , innerlinewidth = 0pt , middlelinewidth = 0pt , outerlinewidth = 0pt , innerleftmargin = 10pt , innerrightmargin = 10pt , innertopmargin = 10pt , innerbottommargin = 10pt , leftmargin = 0.5cm , rightmargin = 0.5cm , skipabove = 0.5cm , skipbelow = 0.1cm , backgroundcolor = #1!10 ] \begin{minipage}{0.075\linewidth} \begin{center} \textcolor{#1}{\fontsize{20pt}{20pt}\selectfont\faIcon{#2}} \end{center} \end{minipage} \begin{minipage}{0.9\linewidth} \textit{\color{#1!70}#3} \end{minipage} \end{mdframed} }

\begin{document}

\annotation {theme} {comment} {Le document a été configuré pour ouvrir les liens dans un nouvel onglet, afin de ne pas écraser celui dans lequel ce trouve le document par une redirection (Si ce document est ouvert dans un navigateur).} \annotation {red} {exclamation} {À ne pas confondre avec les éléments du document, ces derniers portent la même couleur mais en style standard (en non sans Sherif).}

\end{document}

Here's the full code:

\documentclass[12pt, french]{report}
\usepackage[a4paper, total={5.65in, 9.1in}]{geometry} % https://www.ctan.org/pkg/geometry
\usepackage[utf8]{inputenc}                           % https://www.ctan.org/pkg/inputenc
\usepackage[T1]{fontenc}                              % https://www.ctan.org/pkg/fontenc
\usepackage[final]{pdfpages}                          % https://www.ctan.org/pkg/pdfpages
\usepackage[parfill]{parskip}                         % https://www.ctan.org/pkg/parskip
\usepackage[style=numeric]{biblatex}                  % https://www.ctan.org/pkg/biblatex
\usepackage[framemethod=tikz]{mdframed}               % https://www.ctan.org/pkg/mdframed

% babel -> language https://www.ctan.org/pkg/babel % color -> color https://www.ctan.org/pkg/color % tikzpagenodes -> draw figures https://www.ctan.org/pkg/tikzpagenodes % fancyhdr -> stylize header and footer https://www.ctan.org/pkg/fancyhdr % fontawesome5 -> icons https://www.ctan.org/pkg/fontawesome5 % hyperref -> hyperlink https://www.ctan.org/pkg/hyperref % titlesec -> stylize chapter and sections https://www.ctan.org/pkg/titlesec % csquotes -> because ' can cause graphical problems with babel https://www.ctan.org/pkg/csquotes % enumitem -> control over list environments https://www.ctan.org/pkg/enumitem \usepackage{babel, color, tikzpagenodes, fancyhdr, fontawesome5, hyperref, titlesec, csquotes, enumitem}

% Bibliography \addbibresource{ref.bib}

% Defines the colors \definecolor{theme}{HTML}{438DCC} \definecolor{internalLink}{HTML}{707070}

% For header and footer \fancypagestyle{plain}{ \fancyhf{} % Remove what was before \setlength{\headheight}{15pt} \renewcommand{\headrulewidth}{0pt} % Remove the rule after the header

% head -> header
% foot -> footer
% l    -> left
% c    -> center
% r    -> right
\lhead{
    \begin{tikzpicture}[remember picture,overlay]
    \node[xshift=-8.93cm, yshift=-1.94cm] at (current page.north) {\includegraphics{Autre/Header.pdf}};
    \end{tikzpicture}
    \textbf{\textsc{\textcolor{white}{M}argot} Louis}
}
\rhead{\textbf{Rapport de stage}}
\cfoot{\textbf{\textcolor{theme}{--}~\thepage~\textcolor{theme}{--}}}
\rfoot{
    \begin{tikzpicture}[remember picture,overlay]
    \node[xshift=9cm, yshift=0.8cm] at (current page.south) {\includegraphics{Autre/Footer.pdf}};
    \end{tikzpicture}
}

} \pagestyle{plain}

% Hyperlinks \hypersetup{ pdfinfo={ Title={Rapport de stage}, Subject={Conception marketing: Web design, développement}, Author={MARGOT louis} }, linktoc=page, colorlinks=true, filecolor=theme, menucolor=theme, urlcolor=theme, linkcolor=internalLink, citecolor=internalLink, pdfnewwindow=true, bookmarksnumbered=true, bookmarksopen=true }

% Lorem ipsum \usepackage{lipsum}

% Personalization ToC \setcounter{secnumdepth}{1} \setcounter{tocdepth}{2}

% Personalization chapter and sections % % \titleformat{<command>}[<shape>]{<format>}{<label>}{<sep>}{<before-code>}[<after-code>] % <command> is the sectioning command to be redefined: \part, \chapter, \section, \subsection, \subsubsection, \paragraph or \subparagraph. % <shape> is sectioning paragraph shape; possible values are: hang, block, display, runin, leftmargin, rightmargin, drop, wrap, frame. % <format> is the format to be applied to the title, label, and text; for example \normalfont\Large\bfseries % <label> specify sectioning label. % <sep> is the horizontal separation between label and title body and it must be a length and not be empty. % <before-code> is code preceding the title body. % <after-code> is code following the title body. \titleformat{\chapter}[hang]{\normalfont\Huge\bfseries}{\thechapter\hspace{20pt}\textcolor{theme}{|}\hspace{20pt}}{0pt}{\Huge\bfseries} \titleformat{\section}[hang]{\normalfont\Large\bfseries}{\thesection\hspace{15pt}\textcolor{theme}{|}\hspace{15pt}}{0pt}{\normalfont\Large\bfseries} \titleformat{\subsection}[hang]{\normalfont\large\bfseries}{\textcolor{theme}{|}\hspace{10pt}}{0pt}{\normalfont\large\bfseries} \titleformat{\subsubsection}[hang]{\normalfont\normalsize\bfseries}{\textcolor{theme}{|}\hspace{5pt}}{0pt}{\normalfont\normalsize\bfseries} \titleformat{name=\chapter,numberless}[hang]{\normalfont\Huge\bfseries}{}{0pt}{\textcolor{theme}{|}\hspace{20pt}} \titleformat{name=\section,numberless}[hang]{\normalfont\Large\bfseries}{}{0pt}{\textcolor{theme}{|}\hspace{15pt}} \titleformat{name=\subsection,numberless}[hang]{\normalfont\large\bfseries}{}{0pt}{\textcolor{theme}{|}\hspace{10pt}} \titleformat{name=\subsubsection,numberless}[hang]{\normalfont\normalsize\bfseries}{}{0pt}{\textcolor{theme}{|}\hspace{5pt}}

% Personalization lists \setlist[itemize]{label=\textcolor{theme}{---}} \setlist[enumerate]{label=\textcolor{theme}{\arabic*.}}

% Boxes % % \annotation % {color} % {icon} % {text} \newcommand\annotation[3] { \begin{mdframed}[ innerlinewidth = 2pt , roundcorner = 10pt , innerlinewidth = 0pt , middlelinewidth = 0pt , outerlinewidth = 0pt , innerleftmargin = 10pt , innerrightmargin = 10pt , innertopmargin = 10pt , innerbottommargin = 10pt , leftmargin = 0.5cm , rightmargin = 0.5cm , skipabove = 0.5cm , skipbelow = 0.1cm , backgroundcolor = #1!10 ] \begin{minipage}{0.075\linewidth} \begin{center} \textcolor{#1}{\fontsize{20pt}{20pt}\selectfont\faIcon{#2}} \end{center} \end{minipage} \begin{minipage}{0.9\linewidth} \textit{\color{#1!70}#3} \end{minipage} \end{mdframed} }

\begin{document} \include{paper} \end{document}

Thank you for reading, I hope we can fix it together!

--MARGOT Louis--

imnothere
  • 14,215
  • God I'm so dummy... I just had to go to the FIRST page of the FontAwesome5's document for the even width part: \usepackage[fixed]{fontawesome5}

    So the question is how to \linewidth a font.

    – Louis Margot Jun 06 '21 at 13:25

1 Answers1

2

If you want the fontsize to be the linewidth, you can just replace \fontsize{20pt}{20pt} with \fontsize{\linewidth}{\linewidth}.

But official Font Awesome JavaScript code always uses a width of 1.5em for fixed width icons since some are wider than the fontsize. Therefore I would recommend using 0.666\linewidth instead. (Since 0.666 is approximately 1/1.5):

\documentclass{report}
\usepackage[framemethod=tikz]{mdframed} % https://www.ctan.org/pkg/mdframed

% color -> color https://www.ctan.org/pkg/color % tikzpagenodes -> draw figures https://www.ctan.org/pkg/tikzpagenodes % fontawesome5 -> icons https://www.ctan.org/pkg/fontawesome5 \usepackage{color, tikzpagenodes} \usepackage[fixed]{fontawesome5}

% Defines the colors \definecolor{theme}{HTML}{438DCC} \definecolor{internalLink}{HTML}{707070}

% Boxes % % \annotation % {color} % {icon} % {text} \newcommand\annotation[3] { \begin{mdframed}[ innerlinewidth = 2pt , roundcorner = 10pt , innerlinewidth = 0pt , middlelinewidth = 0pt , outerlinewidth = 0pt , innerleftmargin = 10pt , innerrightmargin = 10pt , innertopmargin = 10pt , innerbottommargin = 10pt , leftmargin = 0.5cm , rightmargin = 0.5cm , skipabove = 0.5cm , skipbelow = 0.1cm , backgroundcolor = #1!10 ] \begin{minipage}{0.075\linewidth} \begin{center} \textcolor{#1}{\fontsize{0.666\linewidth}{0.666\linewidth}\selectfont\faIcon{#2}} \end{center} \end{minipage} \begin{minipage}{0.9\linewidth} \textit{\color{#1!70}#3} \end{minipage} \end{mdframed} }

\begin{document}

\annotation {theme} {comment} {Le document a été configuré pour ouvrir les liens dans un nouvel onglet, afin de ne pas écraser celui dans lequel ce trouve le document par une redirection (Si ce document est ouvert dans un navigateur).} \annotation {red} {exclamation} {À ne pas confondre avec les éléments du document, ces derniers portent la même couleur mais en style standard (en non sans Sherif).}

\end{document}