Page LayoutEnumerate Items Below Tikz

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
tpa77l3
Posts: 19
Joined: Mon Feb 24, 2020 9:49 pm

Enumerate Items Below Tikz

Post by tpa77l3 »

Hi guys,

I'm having trouble positioning a tikzpicture where I'd like it in relation to the \item I'm nesting it under.

Code: Select all

\begin{enumerate}[label=\roman*)]
	\item Where A is the age in years of a junior runner, A $<$ 16 reads as `A is less than 16'.
	\vspace {3mm}
	\item
	\begin{figure}[H]
	\centering
	\begin{tikzpicture}[
    dot/.style={draw, fill=#1, circle, inner sep=1.5pt},
    filled/.style={dot},
    open/.style={dot=white}
]
\begin{axis}[
    x=12mm,
    axis y line=none,
    axis x line=center,
    xtick align=outside,
    xtick={9,...,16},
    xmin=8, xmax=17, 
    ymin=0, ymax=1,
    xlabel=$x$,
    xlabel style={anchor=north}
]
\addplot [black]
    coordinates {(9,.1) (16,.1)} 
        node [filled, at start] {}
        node [open] {}
        node [above, midway] {A}
;
\end{axis}
\end{tikzpicture}
\end{figure}
\end{enumerate}
Gives:
Screenshot 2020-02-27 at 04.39.21.png
Screenshot 2020-02-27 at 04.39.21.png (16.18 KiB) Viewed 6305 times
I'm looking to have the second item number [ii)] above the number line. I've played around with some float options but haven't had any luck. What am I doing wrong? Thanks in advance!
Last edited by cgnieder on Sun Mar 01, 2020 5:18 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

Enumerate Items Below Tikz

Post by Bartman »

Please remember to offer a complete example.

You don't need the figure environment to insert a picture. Add baseline=(current bounding box.north) to the options list of the environment tikzpicture.

Code: Select all

\documentclass{article}
\usepackage{enumitem}
\usepackage{csquotes}% for \enquote
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}

\begin{document}
\begin{enumerate}[label=\roman*)]
    \item Where A is the age in years of a junior runner, 
    A $<$ 16 reads as \enquote*{A is less than 16}.
    \item
    \begin{tikzpicture}[
        baseline=(current bounding box.north),
        dot/.style={draw, fill=#1, circle, inner sep=1.5pt},
        filled/.style={dot},
        open/.style={dot=white}
    ]
    \begin{axis}[
        x=12mm,
        axis y line=none,
        axis x line=center,
        xtick align=outside,
        xtick={9,...,16},
        xmin=8, xmax=17, 
        ymin=0, ymax=1,
        xlabel=$x$,
        xlabel style={anchor=north}
    ]
    \addplot [black]
        coordinates {(9,.1) (16,.1)} 
            node [filled, at start] {}
            node [open] {}
            node [above, midway] {A}
    ;
    \end{axis}
    \end{tikzpicture}
\end{enumerate}
\end{document}
tpa77l3
Posts: 19
Joined: Mon Feb 24, 2020 9:49 pm

Enumerate Items Below Tikz

Post by tpa77l3 »

Duly noted about the complete example for the future.

Thanks for the input again. I'll take a look at the baseline option to get my head around it and thanks for pointing me in the direction of the csquotes package.
Post Reply