I've been trying to include a monochromatic PDF vector figure in my LaTeX document and change its fill color directly within LaTeX, without using any external tools. I found two main solutions:
- Sol1: Setting the PDF color space to
RGB
and using thedecodearray
option in\includegraphics
. Unfortunately, this method didn't work for me. - Sol2: Using
TikZ
pictures. This method gave me better results but still isn't perfect.
I'm running into two main problems with the TikZ method:
- Inconsistent Fill Color: Even though I used the same color for the top and bottom borders of the hlines in
tblr
, the colors of the figure and the\hline
don’t look the same. - Unwanted Background: The figure has a white background behind it, even though the original figure is black on a transparent background. I set
fill=transparent!0
in the TikZ picture, but it didn’t fix the issue.
Any suggestions on how to resolve these issues?
Original figure is black (you can download it from here: "left_logo.pdf"). Shown on the right side of the attached image.
Here’s the LaTeX code I’m using:
\documentclass{article}
\usepackage[table, dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{fadings}
\usepackage{tabularray}
\UseTblrLibrary{varwidth}
\begin{document}
\begin{tikzfadingfrompicture}[name=left]
\node [fill=transparent!0,draw=none]
{\includegraphics[width=2.05cm,height=2cm]{./Resources/Figures/left_logo}};
\end{tikzfadingfrompicture}
\begin{titlepage}
\pagecolor{gray}
\begin{tblr}{
width=\textwidth,
colspec = {Q[c,2.65cm]X[c]Q[c,2.65cm]},
rowspec = {Q[b]},
hlines={1pt, MidnightBlue},
measure=vbox}
\fbox{
\begin{tikzpicture}[
outer sep=0pt,
inner sep=0pt,
baseline=(current bounding box.center)]
\node[left color=MidnightBlue,right color=MidnightBlue,minimum width=2.16cm,minimum height=1.85cm]{};
\path[scope fading=left,fit fading=false];
\node[fill=transparent!0,minimum width=2.16cm+1mm,minimum height=1.85cm+1mm]{};
\end{tikzpicture}}
&{
\textcolor{MidnightBlue}{Lorem ipsum dolor sit amet} \\
\textcolor{MidnightBlue}{Proin non mauris maximus, pretium} \\
\textcolor{MidnightBlue}{In convallis eros convallis nunc} \\
\textcolor{MidnightBlue}{Integer eleifend sit amet risus} \\
\textcolor{MidnightBlue}{Fusce vulputate ac felis et}
}&
\fbox{\includegraphics[width=2.05cm,height=2cm]{./Resources/Figures/left_logo}}
\end{tblr}
\end{titlepage}
\end{document}
Edit
I forgot to mention that I'm compiling my document with LuaLaTeX
.