# How to Set a Dark Theme in TeXworks

TeXworks does not natively support a dark theme. However, since it is built using the Qt framework, you can apply a custom dark theme using an external stylesheet.

## Step 1: Launch TeXworks with a Custom Stylesheet

You need to tell TeXworks to load a custom stylesheet at startup. Use the following command:

```bash
<texworks_path>\texworks -stylesheet "<stylesheet_path>\darkbg.css"
```

- Replace `<texworks_path>` with the path to your TeXworks executable.
- Replace `<stylesheet_path>` with the path to the folder containing `darkbg.css`.

### On Windows:

Create a shortcut to `texworks.exe`, then:

1. Right-click the shortcut and select **Properties**.
2. In the **Target** field, add the `-stylesheet` option as shown above.

### On Linux and macOS:

You can create a shell alias in your terminal configuration file (e.g., `.bashrc`, `.zshrc`; macOS uses `.profile`), like this:

```bash
alias texworks='texworks -stylesheet "/path/to/darkbg.css"'
```

## Step 2: Download the Stylesheet and Resources

You can find the `darkbg.css` file on the [dark theme GitHub repository](https://github.com/ezellohar/texworks-dark-theme). The repository includes a `res` folder to download, containing several images used by the TeXworks UI.

> **Note:** When applying a custom stylesheet, you must also provide replacement images for certain UI elements (e.g., arrows, icons). Without these, TeXworks may display missing elements as dots or squares.

The stylesheet includes inline comments describing each UI element, so you can easily customize the colors to your preference.

## Step 3: Customize Syntax Highlighting

TeXworks uses a file called `syntax-patterns.txt` to control syntax highlighting. This file is located in the `configuration` folder, which is one of the subfolders inside the main `res` directory of your TeXworks setup.

The default file is designed for light backgrounds, so it’s recommended to replace or edit it to match the dark theme.

A dark-themed version of `syntax-patterns.txt` is also included in the [dark theme repository](https://github.com/ezellohar/texworks-dark-theme).

## Showcase
Here's a comparison between light and dark theme TeXworks.

<img src="https://github.com/user-attachments/assets/3b127ca2-e0ca-470f-a06b-060df11c75f8" alt="Comparison between light and dark theme TeXworks" width="50%" height="50%">