Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a problem with the text showing the inter-elements spacing, I would like it to be in the same orientation as my structure, is there an easy Tikz solution ?

enter image description here

Code :

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\tdplotsetmaincoords{40}{-30}

\begin{document}
\begin{tikzpicture}[tdplot_main_coords]

\def \r{0.5};
\def \d{1.5};
\def \nx{2};
\def \ny{2};
\def \bord{0.11};
\def \hsub{0.1};

\definecolor{cuivre}{rgb}{0.9,0.7,0.4};
\definecolor{ceram}{rgb}{0.92,0.95,0.95};

%masse
\filldraw[fill=gray] (\d-\r-\bord,\d-\r-\bord,-\hsub) 
        --++ (\nx*\d-\r/2,0,0)
        --++ (0,\ny*\d-\r/2,0)
        --++ (-\nx*\d+\r/2,0,0)
        -- cycle; 

%cadre
\filldraw[fill=cuivre] (\d-\r-\bord,\d-\r-\bord,0) 
        --++ (\nx*\d-\r/2,0,0)
        --++ (0,\ny*\d-\r/2,0)
        --++ (-\nx*\d+\r/2,0,0)
        -- cycle; 

%sub1
\filldraw[fill=ceram] (\d-\r-\bord,\d-\r-\bord,0) 
        --++ (0,0,-\hsub)
        --++ (0,\ny*\d-\r/2,0)
        --++ (0,0,\hsub)
        -- cycle;

%sub2
\filldraw[fill=ceram] (\d-\r-\bord,\d-\r-\bord,0) 
        --++ (0,0,-\hsub)
        --++ (\nx*\d-\r/2,0,0)
        --++ (0,0,\hsub)
        -- cycle;

%trous
\foreach \x in {1,...,\nx}{
    \foreach \y in {1,...,\ny}{
        \filldraw[fill=ceram] (\d*\x,\d*\y,0) circle (\r);  
    }
}

\foreach \x in {2,...,\nx}{
    \foreach \y in {2,...,\ny}{
        \filldraw[fill=ceram] (\d*\x-\d/2,\d*\y-\d/2,0) 
        circle (\r);  
    }
}

%espace inter trou 1
\draw[dashed] (\d, \nx*\d,\hsub) --++ (0,1.5,0);
\draw[dashed] (2*\d, \nx*\d,\hsub) --++ (0,1.5,0);
\draw[<->] (\d, \nx*\d+1.5,\hsub) -- (2*\d, \nx*\d+1.5,\hsub) node
[font=\footnotesize,midway, fill=white, anchor=center]{1.5mm};

\end{tikzpicture}
\end{document}
share|improve this question
    
It is quite easy, just add it as my answer in this question: tex.stackexchange.com/questions/46682/…, the key is simply to add the new coordinate system to the node as well. However, getting the sizes "correct" while changing coordinate system can be quite tricky. :) –  zeroth Jan 26 at 17:57

1 Answer 1

up vote 7 down vote accepted

Just add sloped as argument of your last node. above makes the text not cross the line.

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\tdplotsetmaincoords{40}{-30}

\begin{document}
\begin{tikzpicture}[tdplot_main_coords]

\def \r{0.5};
\def \d{1.5};
\def \nx{2};
\def \ny{2};
\def \bord{0.11};
\def \hsub{0.1};

\definecolor{cuivre}{rgb}{0.9,0.7,0.4};
\definecolor{ceram}{rgb}{0.92,0.95,0.95};

%masse
\filldraw[fill=gray] (\d-\r-\bord,\d-\r-\bord,-\hsub) 
    --++ (\nx*\d-\r/2,0,0)
    --++ (0,\ny*\d-\r/2,0)
    --++ (-\nx*\d+\r/2,0,0)
    -- cycle; 

%cadre
\filldraw[fill=cuivre] (\d-\r-\bord,\d-\r-\bord,0) 
    --++ (\nx*\d-\r/2,0,0)
    --++ (0,\ny*\d-\r/2,0)
    --++ (-\nx*\d+\r/2,0,0)
    -- cycle; 

%sub1
\filldraw[fill=ceram] (\d-\r-\bord,\d-\r-\bord,0) 
    --++ (0,0,-\hsub)
    --++ (0,\ny*\d-\r/2,0)
    --++ (0,0,\hsub)
    -- cycle;

%sub2
\filldraw[fill=ceram] (\d-\r-\bord,\d-\r-\bord,0) 
    --++ (0,0,-\hsub)
    --++ (\nx*\d-\r/2,0,0)
    --++ (0,0,\hsub)
    -- cycle;

%trous
\foreach \x in {1,...,\nx}{
\foreach \y in {1,...,\ny}{
    \filldraw[fill=ceram] (\d*\x,\d*\y,0) circle (\r);  
}
}

\foreach \x in {2,...,\nx}{
\foreach \y in {2,...,\ny}{
    \filldraw[fill=ceram] (\d*\x-\d/2,\d*\y-\d/2,0) 
    circle (\r);  
}
}

%espace inter trou 1
\draw[dashed] (\d, \nx*\d,\hsub) --++ (0,1.5,0);
\draw[dashed] (2*\d, \nx*\d,\hsub) --++ (0,1.5,0);
\draw[<->] (\d, \nx*\d+1.5,\hsub) -- (2*\d, \nx*\d+1.5,\hsub) node
[font=\footnotesize,midway, fill=white, anchor=center,sloped, above]{1.5mm}; %here's the trick

\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
1  
Is it possible to make it in perspective, not only rotated? –  Sigur Jan 26 at 16:58
    
Thank you for this answer. As Sigur mentioned previously, I was looking for a real 3D projection, not only a slopped text, but that's a good start. –  Thomas Jan 26 at 17:02
    
@Thomas Yes, simply add the projection coordinate system to the node as well, see my comment above. –  zeroth Jan 26 at 17:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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