function PapierDIN

% http://geometrie.hs-nb.de/MATLAB-Programme/PapierDIN.m   Bearbeitungsstand: 22.4.2004
% (C) Martin Nitschke, nitschke@hs-nb.de

global ax
ax=[inf -inf inf -inf];
clc;
close('all')
A=[0;0];
a=2^0.25;
b=2^(-0.25);
hold('on');
for k=0:5
    PolygonF([A A+[b;0] A+[b;a] A+[0;a] A],0.875*[1 1 1]);
    plot(A(1)+[0 b],A(2)+[a a]/2,'color',0.875*[1 1 1],'EraseMode','xor','linewidth',0.25)
    Schrift(A+[b;a]/2,['A' int2str(k)],'HorizontalAlignment','center','VerticalAlignment','middle',...
        'FontSize',54*2^(-k/2),'EraseMode','xor')
    Schrift(A+[0;0.25*a],['{\ita}_' int2str(k) '/2'],'HorizontalAlignment','center','verticalAlignment','top',...
        'FontSize',27*2^(-(k+1)/2),'EraseMode','xor','Rotation',90)
    Schrift(A+[0;0.75*a],['{\ita}_' int2str(k) '/2'],'HorizontalAlignment','center','verticalAlignment','top',...
        'FontSize',27*2^(-(k+1)/2),'EraseMode','xor','Rotation',90)
    if k
        Schrift(A+[b/2;0],['{\itb}_' int2str(k) '={\ita}_' int2str(k-1) '/2'],'HorizontalAlignment','center','verticalAlignment','top',...
            'FontSize',27*2^(-k/2),'EraseMode','xor')
        Schrift(A+[0;a/2],['{\ita}_' int2str(k) '={\itb}_' int2str(k-1)],'HorizontalAlignment','center','verticalAlignment','bottom',...
            'FontSize',27*2^(-k/2),'EraseMode','xor','Rotation',90)
    else
        Schrift(A+[b/2;0],['{\itb}_' int2str(k)],'HorizontalAlignment','center','verticalAlignment','top',...
            'FontSize',27*2^(-k/2),'EraseMode','xor')
        Schrift(A+[0;a/2],['{\ita}_' int2str(k)],'HorizontalAlignment','center','verticalAlignment','bottom',...
            'FontSize',27*2^(-k/2),'EraseMode','xor','Rotation',90)
    end
    A(1)=A(1)+1.3*b;
    a0=a;
  a=b;
  b=a0/2;
end
hold('off')
axis('equal')
axis(ax)
axis('off')
print('-deps','PapierDIN');

function PolygonF(P,varargin);
global ax
fill(P(1,:),P(2,:),varargin{:})
if min(P(1,:))<ax(1)
  ax(1)=min(P(1,:));
end
if max(P(1,:))>ax(2)
  ax(2)=max(P(1,:));
end
if min(P(2,:))<ax(3)
  ax(3)=min(P(2,:));
end
if max(P(2,:))>ax(4)
  ax(4)=max(P(2,:));
end

function Schrift(P,txt,varargin)
text(P(1),P(2),txt,'FontName','TimesNewRoman','FontSize',15,varargin{:});
