Removing part of a symbol or image
(This answer was migrated from the original question)
If I understood correctly the question, the following code may help to devise an appropiate solution:
\documentclass{article}
\usepackage{tikz}
\usepackage[margin=2mm]{geometry}
\usepackage{marvosym}
\usepackage{graphicx}
\def\rowofmen#1{%
\begin{tikzpicture}[x=2mm,y=3mm]
\path[clip] (0,0) rectangle (#1,1.1);
\pgfmathparse{ceil(#1)}
\foreach \i in {0,...,\pgfmathresult} {
\node[inner sep=0pt, above right] at (\i, 0)
{\resizebox{2mm}{3mm}{\Gentsroom}};
}
\end{tikzpicture}
}
\begin{document}
\noindent%
\textcolor{gray}{\rowofmen{5}}\\
\textcolor{black!.3!blue}{\rowofmen{3.5}}\\
\rlap{\textcolor{red}{\rowofmen{5}}}%
\rlap{\textcolor{blue}{\rowofmen{3.7}}}%
\rlap{\textcolor{green}{\rowofmen{2.5}}}%
\\
\end{document}
Macro \rowofmen{x}
produces a row of x men, allowing for fractional values of x (the trick is to draw one more man and clipping the resulting figure). Superimposing several of these rows with different colors and lenghts (as in the \rlap
example), you can simulate half-shaded men. This is the output:
Note that each man was resized to 2mm x 3mm. You can alter this by changing the parameters x=2mm,y=3mm
of the tikzpicture
and those of \resizebox
. The remaining can be left unchanged.
I'd clip the symbol with Tik Z instead of drawing a white rectangle over a part of it. That way this also works in front of colored things without having an white box appearing.
I also used the pgfinterruptboundingbox
environment so that the dimensions of \Gentsroom
are known before I can \clip
parts of it (this works similar to \?lap
).
Because the \Gentsroom
is measured this works in lieu with \Large
and similar font-size macros.
Macros
\LeftGent[<>]{<opt>}
and \RightGent[<>]{<opt>}
Is an (empty) optional argument <>
given, then the partly symbol will take the full width of the original symbol.
\setlength{\fboxsep}{0pt}\setlength{\fboxrule}{.2pt}
\fbox{\LeftGent{}\Gentsroom\RightGent{}} \fbox{\LeftGent[]{}\Gentsroom\RightGent[]{}}
The mandatory argument <opt>
(which can be empty, but has to be given) is given to the \node
s:
\RightGent{opacity=.2}\LeftGent{}\RightGent{}\LeftGent{yshift=-.5ex,red}
\partGent[<>]{<opt>}{<perc>}
and \trapGent[<>]{<opt>}{<perc>}
Additional to <>
and <opt>
these macros take an addition argument <perc>
so it is possible to use any arbitrary part of the symbol. Only values between 0.0
and 1.0
make sense, of course.
\rowOfGents[<>]{<opt>}{<count>}
and worOfGents[<>]{<opt>}{<count>}
These macros build an entire row of men. <>
and <opt>
act as usual. <count>
gives the (floating) number of symbols that should be typeset.
\rowOfGents{green}{2.5}\worOfGents{blue}{0.5}\rowOfGents{blue}{0.7}\worOfGents{red}{1.3}\par
\Large\rowOfGents{green}{2.5}\worOfGents{blue}{.5}\rowOfGents{blue}{.7}\worOfGents{red}{1.3}
Code
\documentclass{article}
\usepackage{marvosym}
\usepackage{tikz}
\usetikzlibrary{calc}
\newif\ifclipme
\newcommand*{\LeftGent}[2][\clipmetrue]{\reflectbox{\RightGent[#1]{#2}}}
\newcommand*{\RightGent}[2][\clipmetrue]{\partGent[#1]{#2}{.5}}
\newcommand*{\trapGent}[3][\clipmetrue]{\reflectbox{\partGent[#1]{#2}{#3}}}
\newcommand*{\partGent}[3][\clipmetrue]{%
\sbox0{\Gentsroom}%
\tikz[baseline]
{ #1
\ifclipme\begin{pgfinterruptboundingbox}\fi
\node [anchor=south, inner sep=0pt, outer sep=0pt, text width=\wd0, text height=\ht0, text depth=\dp0, #2] (A) {}; %
\ifclipme\end{pgfinterruptboundingbox}\fi
\clip (A.south west) rectangle ($(A.north west)!#3!(A.north east)$);
\node [anchor=base, inner sep=0pt, outer sep=0pt, #2] {\Gentsroom};
}%
}
\newcommand*{\rowOfGents}[3][\clipmetrue]{%
\pgfmathtruncatemacro\fullGents{int(#3)}%
\pgfmathsetmacro\partGents{mod(#3,1)}%
\ifnum\fullGents>0\relax\foreach \i in {1,...,\fullGents}{\partGent[#1]{#2}{1}}\fi%
\ifdim\partGents pt>0.0pt\relax\partGent[#1]{#2}{\partGents}\fi%
}
\newcommand*{\worOfGents}[3][\clipmetrue]{\reflectbox{\rowOfGents[#1]{#2}{#3}}}
\begin{document}
\setlength{\fboxsep}{0pt}\setlength{\fboxrule}{.2pt}
\fbox{\LeftGent{}\Gentsroom\RightGent{}} \fbox{\LeftGent[]{}\Gentsroom\RightGent[]{}}
\RightGent{opacity=.2}\LeftGent{}\RightGent{}\LeftGent{yshift=-.5ex,red}% That's gonna hurt!
\rowOfGents{green}{2.5}\worOfGents{blue}{0.5}\rowOfGents{blue}{0.7}\worOfGents{red}{1.3}\par
\Large\rowOfGents{green}{2.5}\worOfGents{blue}{0.5}\rowOfGents{blue}{0.7}\worOfGents{red}{1.3}
\end{document}
You can use tikz
to draw a white rectangle over the area you want to clip. Below are two macros \RightHalf
and \LeftHalf
depending on which side you want to clip:
Code:
\documentclass[10pt]{article}
\usepackage{marvosym}
\usepackage{tikz}
\newcommand{\RightHalf}{%
\begin{tikzpicture}%
\node [inner sep=0pt, outer sep=0pt] (A) {\Gentsroom};
\draw [draw=none,fill=white] (A.south west) rectangle (A.north);
\end{tikzpicture}%
}
\newcommand{\LeftHalf}{%
\begin{tikzpicture}%
\node [inner sep=0pt, outer sep=0pt] (A) {\Gentsroom};
\draw [draw=none,fill=white] (A.south east) rectangle (A.north);
\end{tikzpicture}%
}
\begin{document}
\RightHalf \Gentsroom \Gentsroom \LeftHalf
\end{document}