4

I'm just working on a tikzpicture which represents a letter on which you look in a perspective. I just managed to realize this with the shadow and the perspective under Usage of xslant and rotation and shadows.

The goal is to use this letter as a template for many letters. So I just thought about placing writing either with nodes in tikz (possiblity 1) or with textblocks (possibility 2) as you can see in the code. If that works I want to define a command, for example \address which includes everything from the code of the adress so that I only have to change the Names and streets an so on.

All that is quite fine, but now I've got a problem:

The rotated writing in tikz is not really good, because it didn't rotate the line of the font but just the letters. And that's not really pretty :) Maybe there's another way to do this? I hope you can help me a little. Mayber you've got another idea for the problem? Thank you.

(The possiblity 2 in this way is not very useful, because it won't rotate the block, just the letters...)

Here's a working example:

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

This is loosely based on my answer at Plot 3D stacked squares with shadow, which employs Bruno's method at Shear transform a "box"

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

enter image description here

Changing the values, \def\myrotate{-10} \def\myslant{.7}, for example, changes the perspective:

enter image description here

Here is the method adapted into the user's MWE:

enter image description here

and here it is with the coloring removed

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

enter image description here

A parbox input could be implemented by defining

\newcommand\makeply[3]{\mycell{#2}{\parbox[t]{2in}{#1}}{#3}}

However, in either case {\Longstack or \parbox), this answer is not "true" perspective with a vanishing point, but rather an isometric rendition. Thus, while the text may be slanted, it will not get wider towards the bottom of the page.

  • Oh, wow, that's actually very good! Thank you so much! I just printed it and it looks a lot better than my former try. Now I just have to understand the code! ;) Thank you! – buecki Feb 17 '15 at 16:28
3

Obviously only a partial answer, but you can align node labels sloped to a baseline. Maybe you can somehow use the text as a node label for a line that is sloped correctly as your text.

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

screenshot

In your (nice looking) example you could use something like this below. Obviously with white instead of red as line color and better fitting coordinates.

\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}};
  • Thank you for your answer. It really looks a bit smoother. But just try to add a longer text to this (for the actual text of the letter), for example this: \draw [color=black,draw=white] (1.5,-4.6) -- (10,-4.9) node [midway,below,sloped,text width=8cm] {\scriptsize{Lorem Ipsum ...}}; It won't work because of the rotation of the whole document. Is there another way, then create a new \draw for every line? – buecki Feb 17 '15 at 11:01
  • As I said, this is only a partial answer. I hope that the TikZ-Gurus will add their input. – Habi Feb 17 '15 at 11:04
  • 1
    Please note that \scriptsize (like all other font size macros) doesn’t have an argument! It is a switch that changes the font size until the net switch appears or the current group ends. Since the node text is kind of a group you can omit the braces here …] {\scriptsize XXX}; or even better use the font option … font=\scriptsize] {XXX};. The latter makes it possible to make the size part of a style defined with my style/.style={…}. See tex.stackexchange.com/q/7312/4918 for further info about font sizes. – Tobi Feb 17 '15 at 11:55
  • ah, thank you, good to know. I once saw it like this, and just used it. – buecki Feb 17 '15 at 12:12

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.