隐藏部分字母(LaTeX 或 LuaLaTeX)

隐藏部分字母(LaTeX 或 LuaLaTeX)

我正在尝试找出如何排版某些内容然后隐藏部分单词/字母,例如下半部分、上三分之一、首字母等......

那可能吗?

答案1

adjustbox包裹提供方法trimclip盒装内容:

在此处输入图片描述

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

答案2

像这样?

在此处输入图片描述

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

更新

我更新了代码并定义了几种可以轻松应用于任何文本的样式。当然,这些样式只是可以实现的示例。

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

在此处输入图片描述

相关内容