Write Insight Newsletter · · 4 min read

Master TikZ Figures with ChatGPT for High-Impact Academic Writing in LaTeX

Asian graduate student working in front of her computer in a busy Cafe on figures and tables for her academic paper.
Student working figures for the paper.

I am at the CHI 2023 conference this week and receiving so much information (as usual) about everything related to human-computer interaction. I also enjoyed teaching my CHI writing course to a small cohort at this conference again. If you're interested in going through the course slides, you can find them here. One of the things, I taught students in the course is how to quickly create a TikZ figure with the help of ChatGPT when you are writing a paper in LaTeX (this is a markup language that is popular for scientific publications). I want to quickly break down this process for you today. Below you can see the figure we'll be creating.

The TikZ diagram we'll create here with the help of ChatGPT

In academic writing, we frequently create process diagrams, such as experimental flow diagrams, to explain complex processes. We can easily design these using the free TikZ package on the online LaTeX platform Overleaf. The TikZ package is a versatile tool for creating high-quality, customizable graphics, ideal for scientific, mathematical, and engineering diagrams. It supports a variety of features, from simple line drawings to complex 3D visualizations. Overleaf, an online LaTeX editor, enables users to collaborate on documents via a user-friendly interface, offering many templates and examples for seamless project creation and sharing. However, the process of creating a TikZ figure in Overleaf can be time-consuming, especially for someone not proficient in LaTeX, like myself. To efficiently create a figure in this code, I sought assistance from ChatGPT. Here's how I proceeded:

  1. Think about the type of diagram and how to describe it in natural language. I then prompted ChatGPT-4 the following: "Act as a LaTeX code expert. I want to create a horizontal flow diagram using TikZ to show the experimental setup flow with blocks. Generate TikZ code for a box flow diagram that shows this flow: RQ -> Literature Review -> Var 1 Test -> Exposure to Var 1 Test -> Post-test Questionnaires -> User Interviews -> Debrief." You can see that I told ChatGPT explicitly what I wanted to do and gave a brief breakdown of the process flow without making it too complex yet. It's important to mention that it should be horizontal, so it does not just move around the blocks in circles. It continued to generate usable LaTeX code TikZ code, starting with the inclusion of the package for the document: \usepackage{tikz} \usetikzlibrary{shapes,arrows,positioning}
  2. Then, I decided I wanted to add colour (specifically the CHI 2023 colours) and make everything look more uniform. The prompt continued as: "Make all the boxes the same height to look more uniform. Then, I want to colour the background of the boxes in a complementary colour scheme inspired by these colours: #107AC1, #FBC63D, #C53E31. Ensure good contrast ratios between text and background colours. Make the connecting arrows thicker. Break down the text inside the boxes into two lines. Make the font inside the text boxes larger. Be sure to use xcolor to create colour definitions first."
  3. It continued to produce an interesting diagram. I had to make sure \usepackage{xcolor} was included in the header. I then asked it to rename colours ("Change the colour names from color1, etc. to names that represent the colours. Make the colour semitransparent at an alpha level of 70%"). Now, all that was left to do was add the splitting of variables in the experimental design and add a second row of boxes for this. I did this, but I explicitly said what I needed the diagram to look like.
  4. Here is the final prompt: "I want to add a box under Var 1 Test called Var 2 Test and split the input arrow from Literature Review to go towards that as well. Connect this to a box called Exposure to Var 2 test right under Var 1 test, connect this box back to the same Post-test questionnaires box." This continued to produce the image you see above.

This little experiment showed me how quickly I can create awesome-looking TikZ figures with half of the code tinkering that I usually do to get them to look right. Hope this little tip is helpful to you. I will continue to enjoy the CHI conference, and if you're on Twitter, feel free to follow my journey there.

Curious to explore how we can tackle your writing struggles? I've got 3 suggestions that could be a great fit.

  1. Get my CHI paper writing masterclass: Unlock your potential with the How to Write Better Papers Course for HCI researchers. This course offers concise, actionable video lessons you can absorb at your own pace, saving you time. Get expert guidance tailored for CHI and HCI publications with proven strategies. Gain the skills to succeed in a competitive field.
  2. Learn how to write papers with AI ethically: Access the AI Research Tools Webinar to improve your research and writing skills. Enjoy a 3-hour tutorial with subtitles in 19 languages, 46 detailed slides, and a 1-hour ChatGPT bonus tutorial with 39 prompts. Learn from 3 app tutorials (Yomu AI, SciSpace, and Sourcely) and get a 184-page Mastery Guide on 34 AI tools. This bundle provides everything you need for AI-powered academic success.
  3. Defend your thesis with confidence: Increase your productivity and graduate success with this thesis workshop. Get instant access to a 3-hour video, 64 instructional slides, and curated productivity software. Use our online whiteboard and a 7-page workbook of checklists and prompts. Prepare confidently with a 10-page Viva questions guide and a PhD exam checklist. Optimize your thesis workflow and excel in your studies.

Read next