Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Tidying up and posing a secondary question which was answered

I'm trying to put together a visual aid of people numbers in a particular area, so I imagine using something like. Answered elsewhere using the marvosym package with \Gentsroom as the symbol.

Man image

Is there an easy way to shade out half the image e.g. If I'm using each figure to represent four people and I want to indicate 2 by using half a figure?

Link to earlier question below Question on human shape in tikz

Note: The title is terrible but all I can think of. Please feel free to edit it.

share|improve this question
    
“Shade” reads like you want to shade it, i.e making it gray-ish. “Using half a figure” reads like the title should be “Removing part of a symbol or image”. –  Qrrbrbirlbel Nov 27 '12 at 3:43
    
thanks @Qrrbrbirbel, done. –  Tahnoon Pasha Nov 27 '12 at 8:33

3 Answers 3

up vote 14 down vote accepted

(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:

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.

share|improve this answer

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[]{}}

enter image description here

The mandatory argument <opt> (which can be empty, but has to be given) is given to the \nodes:

\RightGent{opacity=.2}\LeftGent{}\RightGent{}\LeftGent{yshift=-.5ex,red}

enter image description here

\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}

enter image description here

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}
share|improve this answer
    
+1 for cool red output! –  recluze Nov 27 '12 at 4:58

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:

enter image description here

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} 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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