我正在製作一個 tikzpicture,它代表您從某個角度看的一封信。我只是設法透過使用 xslant 和旋轉和陰影下的陰影和透視來實現這一點。
目標是使用這封信作為許多信件的範本。所以我只是考慮將書寫放置在 tikz 中的節點(可能性 1)或文字區塊(可能性 2)中,正如您在程式碼中看到的那樣。如果可行的話,我想定義一個命令,例如 \address ,其中包括地址代碼中的所有內容,這樣我只需更改名稱和街道等。
一切都很好,但現在我遇到了一個問題:
tikz 中的旋轉書寫效果不太好,因為它沒有旋轉字體的線條,而只是旋轉了字母。這並不是很漂亮:)也許還有另一種方法可以做到這一點?我希望你能幫我一點忙。也許您對這個問題有其他想法?謝謝。
(這種方式的可能性2不是很有用,因為它不會旋轉塊,只會旋轉字母......)
這是一個工作範例:
\documentclass[a4paper]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tabu}
\usepackage{eurosym}
\usepackage{icomma}
\usepackage[absolute,overlay]{textpos}
\usepackage{pgf, tikz, pgfplots}
\usepackage{rotating}
\usepackage{graphicx}
\usetikzlibrary{
arrows,
shapes,
shadows.blur,
positioning,
calc,
intersections,
decorations.text,
backgrounds,
plotmarks,
shadings
}
\begin{document}
\begin{tikzpicture}[rotate=-3,xslant=0.1,scale=0.7,every node/.style={xslant=0.1,transform shape,rotate=1}]
\fill [color=black!20!white,opacity=0.5] (0.15,-2.15) -- (13.15,-2.15) -- (15.15,-20.15) -- (0.15,-20.15) -- cycle;
\draw [color=black!30, fill=white] (0,-2) -- (13,-2) -- (15,-20) -- (7.3,-20) arc (270:220:9.9cm and 3.5cm) arc (-20:0:4cm and 15cm) -- cycle;
%possibility 1:
\node at (1.5,-5.2) [right] {\scriptsize{XXX YYY}};
\node at (1.5,-5.6) [right] {\scriptsize{ZZZ Street}};
\node at (1.5,-6) [right] {\scriptsize{012345 AAAAA}};
\end{tikzpicture}
%possibility 2:
\begin{textblock*}{10cm}(7cm,7cm)
\begin{rotate}{-3}
\parbox[t]{10cm}{Lorem Ipsum\\ Blab\\Bla\\bla\\D\\D\\D\\D\\D}
\end{rotate}
\end{textblock*}
\end{document}
答案1
這大致上是基於我的回答繪製帶有陰影的 3D 堆疊正方形,它採用布魯諾的方法剪切變換“盒子”
\documentclass{article}
\usepackage{xcolor,graphicx}
\usepackage[usestackEOL]{stackengine}
\newsavebox{\foobox}
\newcommand{\slantbox}[2][.5]{\mbox{%
\sbox{\foobox}{#2}%
\hskip\wd\foobox
\pdfsave
\pdfsetmatrix{1 0 #1 1}%
\llap{\usebox{\foobox}}%
\pdfrestore
}}
\def\mycell#1#2{\fcolorbox{black!50}{#1}{#2 }}
\def\makeply#1#2{\mycell{#2}{\Longstack[l]{#1}}}
\def\perspective#1#2{%
\rotatebox{\myrotate}{\slantbox[\myslant]{%
\makeply{#1}{#2}}}
}
\begin{document}
\def\myrotate{-5} \def\myslant{.3}
\perspective{XXX YYY\\ZZZ Street\\012345 AAAAA}{gray!30}
This is back to normal text.
\end{document}
\def\myrotate{-10} \def\myslant{.7}
例如,更改值會改變視角:
以下是適應使用者 MWE 的方法:
這是去掉顏色的
\documentclass[a4paper]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tabu}
\usepackage{eurosym}
\usepackage{icomma}
\usepackage[absolute,overlay]{textpos}
\usepackage{pgf, tikz, pgfplots}
\usepackage{rotating}
\usepackage{graphicx}
\usetikzlibrary{
arrows,
shapes,
shadows.blur,
positioning,
calc,
intersections,
decorations.text,
backgrounds,
plotmarks,
shadings
}
\usepackage{xcolor,graphicx}
\usepackage[usestackEOL]{stackengine}
\newsavebox{\foobox}
\newcommand{\slantbox}[2][.5]{\mbox{%
\sbox{\foobox}{#2}%
\hskip\wd\foobox
\pdfsave
\pdfsetmatrix{1 0 #1 1}%
\llap{\usebox{\foobox}}%
\pdfrestore
}}
\def\mycell#1#2#3{\fcolorbox{#3}{#1}{#2 }}
\newcommand\makeply[3]{\mycell{#2}{\Longunderstack[l]{#1}}{#3}}
\newcommand\perspective[3][black!30]{%
\rotatebox{\myrotate}{\slantbox[\myslant]{%
\makeply{#2}{#3}{#1}}}
}
\begin{document}
\def\myrotate{1} \def\myslant{.1}
\begin{tikzpicture}[rotate=-3,xslant=0.1,scale=0.7,every node/.style={xslant=0.1,transform shape,rotate=1}]
\fill [color=black!20!white,opacity=0.5] (0.15,-2.15) -- (13.15,-2.15) -- (15.15,-20.15) -- (0.15,-20.15) -- cycle;
\draw [color=black!30, fill=white] (0,-2) -- (13,-2) -- (15,-20) -- (7.3,-20) arc (270:220:9.9cm and 3.5cm) arc (-20:0:4cm and 15cm) -- cycle;
%possibility 1:
\node at (1.5,-5.2) [right] {\scriptsize{XXX YYY}};
\node at (1.5,-5.6) [right] {\scriptsize{ZZZ Street}};
\node at (1.5,-6) [right] {\scriptsize{012345 AAAAA}};
\end{tikzpicture}
%possibility 2:
\begin{textblock*}{10cm}(7cm,7cm)
\begin{rotate}{-3}
\perspective[white]{Lorem Ipsum\\ Blab\\Bla\\bla\\D\\D\\D\\D\\D}{white}
\end{rotate}
\end{textblock*}
\end{document}
parbox 輸入可以透過定義來實現
\newcommand\makeply[3]{\mycell{#2}{\parbox[t]{2in}{#1}}{#3}}
然而,在任一情況 {\Longstack
或\parbox
) 中,這個答案都不是具有消失點的「真實」透視,而是等距再現。因此,雖然文字可能傾斜,但它不會向頁面底部變寬。
答案2
顯然這只是部分答案,但您可以將節點標籤sloped
與基線對齊。也許您可以以某種方式使用文字作為與文字正確傾斜的線條的節點標籤。
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\fill (0,0) circle (0.1);
\fill (3,-1) circle (0.1);
\draw (0,0) -- (3,-1) node [midway, above, sloped] {Sloped text};
\end{tikzpicture}
\end{document}
在你的(漂亮的)範例中,你可以使用如下所示的內容。顯然用white
代替red
線條顏色和更好的擬合座標。
\draw [red] (1.6,-5.2) -- (4.05,-4) node [black, midway, sloped] {\scriptsize{XXX YYY}} ;
\draw [red] (1.6,-5.6) -- (4,-5.5) node [black, midway, sloped] {\scriptsize{ZZZ Street}};
\draw [red] (1.6,-6) -- (3.95,-7.05) node [black, midway, sloped] {\scriptsize{012345 AAAAA}};