LaTeX forum ⇒ Graphics, Figures & TablesTrying to replicate this Gantt chart

Information and discussion about graphics, figures & tables in LaTeX documents.
User avatar
ncant
Posts: 1
Joined: Mon Jun 03, 2024 9:58 pm

Trying to replicate this Gantt chart

Postby ncant » Mon Jun 03, 2024 10:11 pm

Hello everyone,
I want to replicate some Gantt charts shown in the book “Operating System Concepts” to demonstrate how CPU scheduling algorithms work, like this one:

Image

I tried to replicate it using the pgfgantt package and this is what I got:

\documentclass{article}
\usepackage{pgfgantt}

\begin{document}

\begin{figure}
\centering
\begin{ganttchart}[%
inline, 
bar inline label anchor=west,
bar inline label node/.append style={anchor=west, text=black},
bar/.append style={fill=white!!black,}, 
bar height=.8,]{0}{30}
\ganttbar{$P_1$}{0}{24}
\ganttbar{$P_2$}{24}{27}
\ganttbar{$P_3$}{27}{30}
\end{ganttchart}
\end{figure}

\end{document}



which results in the following figure:

Image

What I want to do (but am unable to despite reading the package documentation) is the following:

    - remove the top white bar
    - center the text of the respective blocks
    - make sure that the content of the figure does not exceed the allowed area on the page, at the same time keeping the numeric indices I used to define the “length” of each segment
    - have numerical indices, just like in the original figure.

Can someone help me (or in case propose an alternative method) please?

Recommended reading 2021:

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

Exclusive June 2024 offer: All LaTeX eBooks (PDF, EPBUB) for $9.99 or €8.99

LaTeX books

User avatar
Stefan Kottwitz
Site Admin
Posts: 10191
Joined: Mon Mar 10, 2008 9:44 pm

Trying to replicate this Gantt chart

Postby Stefan Kottwitz » Tue Jun 04, 2024 2:44 pm

Hi ncant,

welcome to the forum!

How about making it a simple TikZ picture? Just three rectangular nodes and four labels.

Stefan
LaTeX.org admin


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 48 guests