I'm currently writting a book in xelatex, and in the progress of creating a couple of highlight boxes, I've encountered a problem.
Some boxes have titles and some doesn't have, because of that, the icon of the box get misplaced.
I've tried using \ifx
, but that didn't work.
Here is the MWE:
% !TEX encoding = UTF-8
% !TEX spellcheck = es_ES
\PassOptionsToPackage{x11names,table,usenames}{xcolor}
\documentclass[a4]{article}
\usepackage{lipsum}
\usepackage{tikz} % Para poder dibujar
\usetikzlibrary{calc,matrix,shapes,arrows,automata,positioning,graphs,arrows.meta,decorations.pathreplacing,svg.path,shapes.symbols,shadows,backgrounds}
\usepackage{fontawesome}
\usepackage[most]{tcolorbox}
\usepackage{fontspec}
\setmonofont{Iosevka}[Scale=0.9]
\usepackage{calc}
\usepackage{xcolor}
%----------------------------------------------------------------------------------------
% Highlight Boxes
%----------------------------------------------------------------------------------------
\newfontfamily\titleboxfont{Fira Sans} % Font
\newfontfamily\boxfont{Fira Sans Light} % Font
\tcbset{mybox/.style={
enlarge top initially by=5mm,
enlarge bottom finally by=5mm,
fonttitle=\titleboxfont\bfseries,
drop fuzzy shadow,
height=3cm,
height plus=10cm,
enhanced,
% center,
left=0pt,
right=0pt,
top=8pt,
bottom=8pt,
enlarge left by=0mm,
boxsep=5pt,
fontupper=\small\boxfont,
arc=4pt,
outer arc=4pt,
leftupper=1.5cm,
width=0.9\linewidth,
title={#1}
}
}
\colorlet{boxinfocolor}{blue}
\newtcolorbox{pinfobox}[1]{
mybox=#1,
colback=boxinfocolor!5!white,
colframe=boxinfocolor!75!black,
overlay={
% \ifx #1\empty
% \node[anchor=north west] at ([xshift=10pt,yshift=-0.65\baselineskip]frame.north west)
% \else
\node[anchor=north west] at ([xshift=10pt,yshift=-2.65\baselineskip]frame.north west)
% \fi
{{\color{boxinfocolor!75!black}\fontsize{10mm}{10mm}\selectfont\faInfoCircle}};
}
}
\newenvironment{infobox}[1]{%
\begin{figure}[htp]
\begin{pinfobox}{#1}
}
{
\end{pinfobox}
\end{figure}
}
\begin{document}
\begin{infobox}{Lipsum}
\lipsum[1]
\end{infobox}
\begin{infobox}{}
\lipsum[2]
\end{infobox}
\end{document}
In the following picture you can see what is happening.
Thanks for your help.