-1

I would like to plot a figure like the attached using latex environment. I know it can be achieved using other software, such as CAD, but the figure created by LaTex looks more beautiful. Anyone can help me out?

PS: Don't have to be identical with the attached Fig.

enter image description here

pluton
  • 16,421
user22986
  • 1,421
  • 3
    You could make this using TikZ – erik Apr 07 '15 at 14:31
  • 3
    http://latex-community.org/know-how/472-tikz-structural-analysis – Johannes_B Apr 07 '15 at 14:37
  • 8
    Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. – Alan Munn Apr 07 '15 at 14:38
  • @Johannes_B: Thanks for leading me to the very useful link. – user22986 Apr 07 '15 at 14:45
  • @erik: I am not good at tikz. If you can leave the detailed implementation, it would be greatly appreciated. – user22986 Apr 07 '15 at 14:47
  • 4
    @user22986 Then this is the perfect time for learning it. Tikz has a user manual and there are many example codes available online (just google it). Try to produce it, learn how it works, then, when you have specific questions, come back. This is especially advisable since this is not the first time you would benefit from that expertise and will likely not be the last time. – Manuel Weinkauf Apr 07 '15 at 14:54
  • 4
    @user22986 Sorry, but that's not how this site works. If you invest some time and effort, then come here when you get stuck, you will find plenty of help. However, posts that basically say "someone please do this for me" are not well received. – erik Apr 07 '15 at 15:03

1 Answers1

6

Well here's most of what your diagram demonstrates. I've added a few comments throughout that hopefully help you understand better what I've done.

I've heavily used the calc library. I've also used the patterns library to get the dots inside the side rectangle.

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{patterns}
\usetikzlibrary{arrows.meta}

\begin{document}

\begin{tikzpicture}

  %% defining the corners of the grill
  \coordinate (grill/sw) at (0,0);
  \coordinate (grill/ne) at ($(grill/sw)+(5in,1cm)$);
  \coordinate (grill/nw) at (grill/sw|-grill/ne);
  \coordinate (grill/se) at (grill/sw-|grill/ne);

  %% filling the grill
  \draw[fill=gray!20] (grill/sw) rectangle (grill/ne);

  %% drawing the horizontal bars of the grill  
  \def\mymax{7}
  \foreach \myn in {0,1,...,\mymax}
  {
    \draw ($(grill/sw)!\myn/\mymax!(grill/nw)$)
       -- ($(grill/se)!\myn/\mymax!(grill/ne)$);
  }

  %% material above the grill 
  %% downward arrows 
  \def\myarrowheight{1cm}
  \def\myarrowcount{12}
  \foreach \myn in {0,1,...,\myarrowcount}
  {
    \draw[arrows=Stealth-] ($(grill/nw)!\myn/\myarrowcount!(grill/ne)$) -- ++ (0,\myarrowheight);
  }
  %% label above downward arrows
  \path ([yshift=\myarrowheight+2ex]grill/nw) --
        ([yshift=\myarrowheight+2ex]grill/ne)
        node[midway] {$q$};

  %% material below the grill
  %% grill label
  \path (grill/sw) -- (grill/se)  node[midway,below] {$E_r,E_m,\rho_r,\rho_m,f$};
  %% corner decorations
  %% isosceles triangle
  \def\myr{1.5ex}
  \draw[fill=red] (grill/sw) -- ++ (-60:{\myr*2/sin(60)})
                             -- ++ (180:{\myr*2/sin(60)})
                             -- cycle;
  %% circle
  \draw[fill=red] ($(grill/se)+(down:\myr)$) circle (\myr);

  %% hash marks under corner decorations
  \begin{scope}[myyshift/.style={yshift={-2*\myr}}]

    \def\mystepmax{4}
    \def\mystepwidth{5pt}
    \def\mystepheight{6pt}
    \foreach \myside in {se,sw}
    {
      \foreach \myn in {1,...,\mystepmax}
      {
        \pgfmathsetmacro\myxshift{ (-\mystepmax /2+\myn)*\mystepwidth  -\mystepwidth}
        \draw ([myyshift,xshift=\myxshift]grill/\myside) --
              ([myyshift,xshift={\myxshift+\mystepwidth}]grill/\myside)   --
              ([myyshift,yshift=-\mystepheight,xshift=\myxshift]grill/\myside);
      } 
    }

  \end{scope}

  \pgfmathsetmacro\myyshift{5ex+2*\myr}
  \begin{scope}[myshift/.style={yshift={-\myyshift}}]

     \path
           ([myshift]grill/sw)
           --
           ([myshift]grill/se)
           node [midway] {L}
           edge[arrows=->] ([myshift]grill/se)
           edge[arrows=->] ([myshift]grill/sw);
     \foreach \myn in {se,sw}
     {
       \draw ([myshift]grill/\myn)
             edge ++(up:3ex)
             edge ++(down:3ex);       
     }  

  \end{scope}

  \draw ($(grill/ne)+(1cm,0)$) rectangle ($(grill/se)+(1.5cm,0)$);

  \pattern[pattern=crosshatch dots gray]  ($(grill/ne)+(1cm,0)$) rectangle ($(grill/se)+(1.5cm,0)$);
\end{tikzpicture}


\end{document}

enter image description here

The techniques you need to know to finish the diagram has already been demonstrated in the above code.

There might be easier (better) approaches to some of the things I've done. I leave that for someone else better acquainted with tricks of TikZ to demonstrate.

A.Ellett
  • 50,533