15

I'm trying to find out how to typeset something and then hide part of the words/letters, e.g. the bottom half, the top third, the first letters, etc...

Is that possible?

18

The adjustbox package provides ways to trim and clip boxed content:

enter image description here

\documentclass{article}

\usepackage{adjustbox}

\begin{document}

Horizontal hiding:
\begin{itemize}
  \item --something--
  \item --\phantom{some}thing--
  \item --some\hphantom{thing}--
  \item --\adjustbox{trim=0pt 0pt 17pt 0pt,clip,lap=\width}{something}\phantom{something}--
  \item --\phantom{something}\adjustbox{trim=.3333\width{} 0pt 0pt 0pt,clip,lap=-\width}{something}--
\end{itemize}

Vertical hiding:
\begin{itemize}
  \item --something--
  \item --so\adjustbox{trim=0pt 3pt 0pt 0pt,clip,raise=3pt}{methi}ng--
  \item --\adjustbox{trim=0pt 0pt 0pt .45\height,clip}{something}--
\end{itemize}

\end{document}
  • Fantastic, this seems the way to go... I'll wait a bit before accepting, just in case, but I think this is it. – Moriambar Apr 5 '17 at 7:07
15

Like this?

enter image description here

\documentclass[tikz,border=2mm]{standalone} 
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}

\node[inner sep=0pt] (a) {\LaTeX};

\begin{scope}[yshift=-5mm]
\node[inner sep=0pt] (b) {\LaTeX};
\fill[white] (b.north west)-|(b.east)--cycle;
\end{scope}

\begin{scope}[yshift=-1cm]
\node[inner sep=0pt] (c) {\LaTeX};
\fill[white] (c.north west)-|(c.south)-|cycle;
\end{scope}

\begin{scope}[yshift=-1.5cm]
\node[inner sep=0pt] (d) {\LaTeX};
\fill[white] (d.south west) rectangle (d.east);
\end{scope}

\end{tikzpicture}
\end{document}

Update

I've updated the code and defined several styles which can be easily applied to any text. Of course, these styles are just examples of what can be done.

\documentclass{article} 
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\usepackage{lmodern}

\tikzset{
    show bottom/.style={inner sep=0pt, 
        prefix after command={%
            \pgfextra 
                \clip (\tikzlastnode.south west) rectangle ($(\tikzlastnode.south east)!#1!(\tikzlastnode.north east)$);    
            \endpgfextra}
        },
    show top/.style={inner sep=0pt, 
        prefix after command={%
            \pgfextra 
                \clip (\tikzlastnode.north west) rectangle ($(\tikzlastnode.north east)!#1!(\tikzlastnode.south east)$);    
            \endpgfextra}
        },
    show left/.style={inner sep=0pt, 
        alias=this,
        prefix after command={%
            \pgfextra 
                \clip (\tikzlastnode.north west) rectangle ($(\tikzlastnode.south west)!#1!(\tikzlastnode.south east)$);    
            \endpgfextra}
        },
    show right/.style={inner sep=0pt, 
        prefix after command={%
            \pgfextra 
                \clip ($(\tikzlastnode.north west)!#1!(\tikzlastnode.north east)$) rectangle (\tikzlastnode.south east);    
            \endpgfextra}
        },
    show bottom triangle/.style={inner sep=0pt,
        prefix after command={%
            \pgfextra 
                \clip (\tikzlastnode.south west)--(\tikzlastnode.north)-- (\tikzlastnode.south east) -- cycle;  
            \endpgfextra}
        },      
    show top triangle/.style={inner sep=0pt,
        prefix after command={%
            \pgfextra 
                \clip (\tikzlastnode.north west)--(\tikzlastnode.south)-- (\tikzlastnode.north east) -- cycle;  
            \endpgfextra}
        },
    show inner/.style={inner sep=0pt,
        prefix after command={%
            \pgfextra 
                \clip ($(\tikzlastnode.north west)!#1!(\tikzlastnode.center)$) rectangle ($(\tikzlastnode.south east)!#1!(\tikzlastnode.center)$);  
            \endpgfextra}
        }       
}

\begin{document}

Vertical hiding:
\begin{itemize}
\item \LaTeX
\item \tikz \node[show bottom=.3] {\LaTeX};
\item \tikz \node[show bottom=.8] {\LaTeX};
\item \tikz \node[show top=.3] {\LaTeX};
\item \tikz \node[show top=.8] {\LaTeX};
\end{itemize}

Horizontal hiding:
\begin{itemize}
\item \LaTeX
\item \tikz \node[show left=.3] {\LaTeX};
\item \tikz \node[show left=.8] {\LaTeX};
\item \tikz \node[show right=.3] {\LaTeX};
\item \tikz \node[show right=.8] {\LaTeX};
\end{itemize}

Others:
\begin{itemize}
\item \LaTeX
\item \tikz \node[show bottom triangle] {\LaTeX};
\item \tikz \node[show top triangle] {\LaTeX};
\item \tikz \node[show inner=.2] {\LaTeX};
\end{itemize}

\end{document}

enter image description here

  • This is ok, but how about configuring how much of the word to hide? – Moriambar Apr 5 '17 at 7:12
  • @Moriambar How do you want to define "how much of the word to hide"? – Ignasi Apr 5 '17 at 7:20
  • It depends: if you see the other answer (apart from being integrated seamlessly with normal text), I can specify different point-sizes for the hiding boxes – Moriambar Apr 5 '17 at 7:24
  • 1
    @Moriambar I've updated my answer. Now I've defined some styles which let you decide what part of the word is seen/hidden. With anchors help you can define whatever figure you like to cut the text. – Ignasi Apr 5 '17 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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