0

enter image description hereCould I ask if this is the best way to position diagrams? or should I be using a different method other than in a table?

\documentclass{book}

\usepackage{blindtext}
\usepackage{tikz}
\usepackage{tkz-euclide}

\newcommand{\AB}{0.75}   % A  and B added <<<<<<<<<<<<<<
\newcommand{\C}{1.5}    % C added <<<<<<<<<<<<<<
\newcommand{\AD}{0.75} % D added<<<<<<<<<<<<<<
\newcommand{\Asize}{0.25}   % Angle added <<<<<<<<<<<<<<
\newcommand{\AG}{1.5}

\begin{document}

\begin{center}
\begin{tabular}{ccc}
\begin{tikzpicture}
        \tkzDefPoints{-\AB/0/A,\AB/0/B,0/\C/C,1/\AD/D}

        \tkzDefPointOnLine[pos=0.5](B,C)\tkzGetPoint{E}

    \tkzDrawPolygon(A,B,C)
    %\tkzDrawPolygon(A,B,D)

    \tkzLabelPoints[left](A)
    \tkzLabelPoints[right](B)
    \tkzLabelPoints[above](C)
    %\tkzLabelPoints[above](D)
  
    \tkzMarkSegment[mark=|](A,C)
    \tkzMarkSegment[mark=||](A,B)
    \tkzMarkAngle[size=\Asize](B,A,C)
    \tkzMarkAngle[size=\Asize](C,B,A)
\end{tikzpicture}
&
\begin{tikzpicture}
     \tkzDefPoints{-\AB/0/A,\AB/0/B,0/\C/C,1/\AD/D}

     \tkzDefPointOnLine[pos=0.5](B,C)\tkzGetPoint{E}

    %\tkzDrawPolygon(A,B,C)
    \tkzDrawPolygon(A,B,D)

    \tkzLabelPoints[left](A)
    \tkzLabelPoints[right](B)
    %\tkzLabelPoints[above](C)
    \tkzLabelPoints[above](D)
  
    \tkzMarkSegment[mark=|](A,D)
    \tkzMarkSegment[mark=|](A,B)
    %\tkzMarkAngle[size=\Asize](B,A,C)
    %\tkzMarkAngle[size=\Asize](C,B,A)
\end{tikzpicture}
&
\begin{tikzpicture}
\tkzDefPoints{-\AB/0/A,\AB/0/B,0/\C/C,1/\AD/D}

        \tkzDefPointOnLine[pos=0.5](B,C)\tkzGetPoint{E}

    \tkzDrawPolygon(A,B,C)
    \tkzDrawPolygon(A,B,D)

    \tkzLabelPoints[left](A)
    \tkzLabelPoints[right](B)
    \tkzLabelPoints[above](C)
    \tkzLabelPoints[above](D)
  
    %\tkzMarkSegment[mark=|](A,D)
    %\tkzMarkSegment(D,C)
    \tkzMarkAngle[size=\Asize](B,A,C)
    \tkzMarkAngle[size=\Asize](C,B,A) 
\end{tikzpicture}
\end{tabular}
\end{center}

\end{document}

I know people helped me on this to get it this way but I am just trying to improve myself. I am just a little worried all my code seems a bit all over the place, I am just trying to tidy it up a bit. Including all the repeating code for each diagram.

3
  • 1
    Can you please add a screenshot to your question? What do you like about your current solution, what do you dislike (besides non-refactored Tikz-code) ?
    – MS-SPO
    Commented Nov 27, 2023 at 19:15
  • 1
    Why not simply put the 3 codes in sequence?
    – Sigur
    Commented Nov 27, 2023 at 19:36
  • I just think all the code looks messy, it might just be me. But I am constantly finding I am doing things the long way round and not the 'proper' way.
    – Paul A
    Commented Nov 27, 2023 at 19:37

2 Answers 2

2

Could I ask if this is the best way to position diagrams?

Since you haven't specified any optimality criteria for positioning diagrams in an appealing manner, it's not possible to judge what may be best. Your method certainly works -- which is always a plus.

That said, it doesn't appear to be the case that the tabular machinery really adds any extra capabilities that aren't available by simply placing the diagrams next to each other, separated by \quad, \qquad, or (say) \hspace{1cm}.

enter image description here

\documentclass{book}
\usepackage{tikz,tkz-euclide}

\newcommand{\AB}{0.75}  % A and B added <<<<<<<<<<<<<<
\newcommand{\C}{1.5}    % C added <<<<<<<<<<<<<<
\newcommand{\AD}{0.75}  % D added<<<<<<<<<<<<<<
\newcommand{\Asize}{0.25} % Angle added <<<<<<<<<<<<<<
\newcommand{\AG}{1.5}

\begin{document}

\begin{center}
%%%\begin{tabular}{ccc}
\begin{tikzpicture}
   \tkzDefPoints{-\AB/0/A,\AB/0/B,0/\C/C,1/\AD/D}
   \tkzDefPointOnLine[pos=0.5](B,C)\tkzGetPoint{E}

    \tkzDrawPolygon(A,B,C)
    %\tkzDrawPolygon(A,B,D)

    \tkzLabelPoints[left](A)
    \tkzLabelPoints[right](B)
    \tkzLabelPoints[above](C)
    %\tkzLabelPoints[above](D)
  
    \tkzMarkSegment[mark=|](A,C)
    \tkzMarkSegment[mark=||](A,B)
    \tkzMarkAngle[size=\Asize](B,A,C)
    \tkzMarkAngle[size=\Asize](C,B,A)
\end{tikzpicture}%
\hspace{1cm} %%% &
\begin{tikzpicture}
    \tkzDefPoints{-\AB/0/A,\AB/0/B,0/\C/C,1/\AD/D}
    \tkzDefPointOnLine[pos=0.5](B,C)\tkzGetPoint{E}

    %\tkzDrawPolygon(A,B,C)
    \tkzDrawPolygon(A,B,D)

    \tkzLabelPoints[left](A)
    \tkzLabelPoints[right](B)
    %\tkzLabelPoints[above](C)
    \tkzLabelPoints[above](D)
  
    \tkzMarkSegment[mark=|](A,D)
    \tkzMarkSegment[mark=|](A,B)
    %\tkzMarkAngle[size=\Asize](B,A,C)
    %\tkzMarkAngle[size=\Asize](C,B,A)
\end{tikzpicture}%
\hspace{1cm} %%% &
\begin{tikzpicture}
    \tkzDefPoints{-\AB/0/A,\AB/0/B,0/\C/C,1/\AD/D}
    \tkzDefPointOnLine[pos=0.5](B,C)\tkzGetPoint{E}

    \tkzDrawPolygon(A,B,C)
    \tkzDrawPolygon(A,B,D)

    \tkzLabelPoints[left](A)
    \tkzLabelPoints[right](B)
    \tkzLabelPoints[above](C)
    \tkzLabelPoints[above](D)
  
    %\tkzMarkSegment[mark=|](A,D)
    %\tkzMarkSegment(D,C)
    \tkzMarkAngle[size=\Asize](B,A,C)
    \tkzMarkAngle[size=\Asize](C,B,A) 
\end{tikzpicture}
%%%\end{tabular}
\end{center}

\end{document}
1
  • 1
    Thanks for that.
    – Paul A
    Commented Nov 27, 2023 at 21:15
2

For my taste, we can have the same result, only with the tikz package and with this more simpler code:

\documentclass{article}
\usepackage{tikz}

\begin{document}
    \noindent
    \begin{tikzpicture}
        \draw (0,0) node[below] (A) {A}--(3,0) node[below] (B) {B}--(1.5,4) node[above] (C) {C}--cycle;
        \draw (.5,0) arc(0:69.44:.5);
        \draw (2.5,0) arc(180:110.56:.5);
        \draw (0,0)--(1.5,4) node[pos=.5,sloped] () {|};
        \draw (0,0)--(3,0) node[pos=.5] () {||}; 
        
        \begin{scope}[xshift=5cm]
            \draw (0,0) node[below] (A) {A}--(3,0) node[below] (B) {B}--(4.14,1.04) node[above] (D) {D}--cycle;
            \draw (0,0)--(4.14,1.04) node[pos=.5,sloped] () {|};
            \draw (0,0)--(3,0) node[pos=.5] () {||};
        \end{scope}
        
        \begin{scope}[xshift=11cm]
            \draw (0,0) node[below] (A) {A}--(3,0) node[below] (B) {B}--(1.5,4) node[above] (C) {C}--cycle;
            \draw (.5,0) arc(0:69.44:.5);
            \draw (2.5,0) arc(180:110.56:.5);
            \draw (0,0)--(3,0)--(4.14,1.04) node[right] (D) {D}--cycle;
        \end{scope}
    \end{tikzpicture}
\end{document}

The output is this one:

enter image description here

You can use almost the same code (and coordinates) for each picture.

You must log in to answer this question.

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