0

I am using following solution How can I draw arrow like directory tree format in tikz? inside \documentclass[5p,times]{elsarticle} format.

code:

\documentclass[5p,times]{elsarticle}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
    chains,
    positioning,
    shapes.geometric
}
\begin{document}
\begin{frontmatter}
    \title{Title}
    \author{So Nia}
    \address{Department, University}
    \ead{[email protected]}
    \begin{abstract}
        \lipsum*[2]
    \end{abstract}
\end{frontmatter}
\section{Example}
\begin{tikzpicture}[
        node distance = 4mm and 8mm,
        arr/.style = {-Stealth, semithick},
        C/.style = {circle, draw, font=\footnotesize},
        N/.style = {draw, very thick,
                font=\small, align=left,
                inner sep=5pt}
    ]
    \draw[help lines] (0,0) grid (8,5);
    %
    \node (n1) [N] at (3,4) {\$ gcc -g -c \\
        \hphantom{\$ } -fPIC - Wall \\
        \hphantom{\$ } mod1.c mod2.c mod3.c};
    \node[C, below left = 0 and 2mm of n1.north west] {1};
    \node (n2) [N, below right=of n1.south]     {mod1.o code};
    \node (n3) [N, below=of n2]     {mod2.o code};
    \node (n4) [N, below=of n3]     {mod3.o code};
    %
    \draw[arr] (n1) |- (n2);
    \draw[arr] (n1 |- n2) |- (n3);
    \draw[arr] (n1 |- n3) |- (n4);
\end{tikzpicture}
\lipsum[1-1]
\end{document}

output:

enter image description here

The grid start from where a a paragraphs starts. Here is it possible to force grid start without an indent (I just want to shift it under 1.)?

1. Example
------
|  |  |
|  |  |
------
    Lorem ...
Ut purus ....

1 Answer 1

2

The tikzpicture is a box; here, it starts a new paragraph after \section{Example}. If you put \noindent before \begin{tikzpicture}, the paragraph is started without any indentation.

\documentclass[5p,times]{elsarticle}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{
    arrows.meta,
    chains,
    positioning,
    shapes.geometric
}

\begin{document}
\begin{frontmatter}
    \title{Title}
    \author{So Nia}
    \address{Department, University}
    \ead{[email protected]}
    \begin{abstract}
        \lipsum*[2]
    \end{abstract}
\end{frontmatter}
\section{Example}

\noindent   % <--------------- this
\begin{tikzpicture}[
        node distance = 4mm and 8mm,
        arr/.style = {-Stealth, semithick},
        C/.style = {circle, draw, font=\footnotesize},
        N/.style = {draw, very thick,
                font=\small, align=left,
                inner sep=5pt}
    ]
    \draw[help lines] (0,0) grid (8,5);
    %
    \node (n1) [N] at (3,4) {\$ gcc -g -c \\
        \hphantom{\$ } -fPIC - Wall \\
        \hphantom{\$ } mod1.c mod2.c mod3.c};
    \node[C, below left = 0 and 2mm of n1.north west] {1};
    \node (n2) [N, below right=of n1.south]     {mod1.o code};
    \node (n3) [N, below=of n2]     {mod2.o code};
    \node (n4) [N, below=of n3]     {mod3.o code};
    %
    \draw[arr] (n1) |- (n2);
    \draw[arr] (n1 |- n2) |- (n3);
    \draw[arr] (n1 |- n3) |- (n4);
\end{tikzpicture}

\lipsum[1-1]
\end{document}

enter image description here

2
  • I assume indenting the first paragraph after \section is SOP for elsearticle. Jul 17, 2022 at 18:21
  • @JohnKormylo I don't particularly know elsarticle—simply noted that the paragraph following the \section had indentation that could be removed in the standard way... (Yes, I know that the standard classes have no indentation by default in these places.)
    – frougon
    Jul 17, 2022 at 18:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .