3

Problem: I created a custom dark theme for TeXworks (a LaTeX editor) that I am happy with but I am running into an issue when opening files with the .tex file extension in folders when TeXworks is not activated. I changed via properties my TeXworks toolbar shortcut to append this code to the Target:

C:\texlive\2021\bin\win32\texworks.exe -stylesheet "C:\Users\Acer\Documents\Programming\LaTeX\CSS Styles\darkbg.css"

enter image description here

where darkbg.css is the custom style file that enables the TeXworks editor dark theme. I also appended -stylesheet "C:\Users\Acer\Documents\Programming\LaTeX\CSS Styles\darkbg.css" to my desktop shortcut of TeXworks which when opening .tex files within folders still opened with the default white theme.

Seeing that they were all calling the same .exe, I found the location of the TeXworks executable in C:\texlive\2021\bin\win32\ but when opening the properties, I cannot see a way to append the -stylesheet path to it to set it globally:

enter image description here

The advanced properties do not glean anything useful.

Question: How can I change the texworks.exe executable to launch with the addition of the -stylesheet "C:\Users\Acer\Documents\Programming\LaTeX\CSS Styles\darkbg.css path or via any alternative way? It is only a minor issue as I can open a TeXworks window, then open the file and it automatically loads the dark theme but I would prefer for it not to be like this if possible please!

This is my first question here and I am more used to TeX.SE question etiquette so if you need anything further please ask.

Edit: When changing the registry key found here:

enter image description here

from:

"C:\texlive\2021\bin\win32\texworks.exe" "%1"

to:

"C:\texlive\2021\bin\win32\texworks.exe -stylesheet "C:\Users\Acer\Documents\Programming\LaTeX\CSS Styles\darkbg.css"" "%1"

this window opens when trying to open .tex files:

enter image description here

and clicking okay does not load the file at all. I am assuming I have edited the registry entry incorrectly, I do not know the purpose of the "%1" either, is this what I append to?

piJT
  • 59

1 Answers1

2

You need to change the command that is associated with all .tex files, which requires registry modifications. Ensure you have backups before doing any registry modifications.

I don't have your software installed on my computer, but this is the general way of doing it :

  • Run regedit
  • Position to the key Computer\HKEY_CLASSES_ROOT\.tex
  • You will see on the right a key named (Default)
  • Double-click the key and copy its value, then click Cancel
  • If the value you copied was, say, abcdefg, find on the left a key by that name, meaning named Computer\HKEY_CLASSES_ROOT\abcdefg
  • Drill-down by opening this key - its sub-keys contain the verbs that can be executed on .tex files
  • The sub-keys you are interested in may be called shell or open or view or edit. If unsure, do all of them as follows
  • Open the sub-key, to find a sub-sub-key named command
  • This key will have a (Default) value of type REG_EXPAND_SZ that contains the command to be executed
  • Double-click the value and add your parameter to the command
  • Click OK to terminate - the effect of the change should be immediate.

If the registry entries for .tex are different from my above description, add to your post their screenshots so I can help.


Note: the "%1" means the parameter, which in this case means the file.

Your command had unbalanced double-quotes ("). The command should be:

"C:\texlive\2021\bin\win32\texworks.exe" -stylesheet "C:\Users\Acer\Documents\Programming\LaTeX\CSS Styles\darkbg.css" "%1"
harrymc
  • 498,455