LaTeX forum ⇒ Page LayoutEnumerate Items Below Tikz Topic is solved

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

Enumerate Items Below Tikz

Postby tpa77l3 » Thu Feb 27, 2020 6:42 am

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] [Expand/Collapse] [Download] ({untitled.tex})
  1. \begin{enumerate}[label=\roman*)]
  2. \item Where A is the age in years of a junior runner, A $<$ 16 reads as `A is less than 16'.
  3. \vspace {3mm}
  4. \item
  5. \begin{figure}[H]
  6. \centering
  7. \begin{tikzpicture}[
  8. dot/.style={draw, fill=#1, circle, inner sep=1.5pt},
  9. filled/.style={dot},
  10. open/.style={dot=white}
  11. ]
  12. \begin{axis}[
  13. x=12mm,
  14. axis y line=none,
  15. axis x line=center,
  16. xtick align=outside,
  17. xtick={9,...,16},
  18. xmin=8, xmax=17,
  19. ymin=0, ymax=1,
  20. xlabel=$x$,
  21. xlabel style={anchor=north}
  22. ]
  23. \addplot [black]
  24. coordinates {(9,.1) (16,.1)}
  25. node [filled, at start] {}
  26. node [open] {}
  27. node [above, midway] {A}
  28. ;
  29. \end{axis}
  30. \end{tikzpicture}
  31. \end{figure}
  32. \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 289 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.
Reason: added inline code formatting

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

Postby Bartman » Thu Feb 27, 2020 7:45 am

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] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass{article}
  2. \usepackage{enumitem}
  3. \usepackage{csquotes}% for \enquote
  4. \usepackage{pgfplots}
  5. \pgfplotsset{compat=1.16}
  6.  
  7. \begin{document}
  8. \begin{enumerate}[label=\roman*)]
  9. \item Where A is the age in years of a junior runner,
  10. A $<$ 16 reads as \enquote*{A is less than 16}.
  11. \item
  12. \begin{tikzpicture}[
  13. baseline=(current bounding box.north),
  14. dot/.style={draw, fill=#1, circle, inner sep=1.5pt},
  15. filled/.style={dot},
  16. open/.style={dot=white}
  17. ]
  18. \begin{axis}[
  19. x=12mm,
  20. axis y line=none,
  21. axis x line=center,
  22. xtick align=outside,
  23. xtick={9,...,16},
  24. xmin=8, xmax=17,
  25. ymin=0, ymax=1,
  26. xlabel=$x$,
  27. xlabel style={anchor=north}
  28. ]
  29. \addplot [black]
  30. coordinates {(9,.1) (16,.1)}
  31. node [filled, at start] {}
  32. node [open] {}
  33. node [above, midway] {A}
  34. ;
  35. \end{axis}
  36. \end{tikzpicture}
  37. \end{enumerate}
  38. \end{document}

tpa77l3
Posts: 19
Joined: Mon Feb 24, 2020 9:49 pm

Postby tpa77l3 » Fri Feb 28, 2020 8:17 am

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.


Return to “Page Layout”

Who is online

Users browsing this forum: No registered users and 2 guests