LaTeX forum ⇒ TeXworksCustomize Editor Colors

Information and discussion about TeXworks, an integrated LaTeX environment for several platforms
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Customize Editor Colors

Postby frabjous » Fri Nov 27, 2009 4:44 pm

Some of you may know that you can customize the syntax highlighting colors and patterns for TeXworks by editing the syntax-patterns.txt file in your ~/.TeXworks/configuration directory.

This file, however, does not allow you to change the main editor background color, or the colors of the un-highlighted text.

Thanks largely to st.loeffler at the Google Code project site for TeXworks, I discovered that it is possible to customize the main editor colors. You need to create a custom style sheet mystyle.css using CSS mark-up. It should look like this:
  1. QTextEdit {
  2. background-color: black;
  3. color: white; /* sets the main text color */
  4. }


Or you can use any of the color names of values listed here.

You then need to run TeXworks with the command:

  1. texworks -stylesheet /pathto/mystyle.css


And then you have whatever pretty colors you want. Be sure also to change syntax-patterns.txt (backing up first) to pick syntax-highlighting colors that look good with your new background-color.

There are other things you can customize this way as described here, though I haven't tested that.

The only things you can't change, at least not until they make some improvements to TeXworks, is the colors you get when you have "highlight current line" selected, or the colors used when matching brackets are found. At the moment, I just have the former turned off.

If you're feeling particularly adventurous, you can even substitute a background image for your editor screen.
  1. QTextEdit {
  2. background-image: url('/pathto/mybackground.png');
  3. color: white; /* sets the main text color */
  4. }

Of course you have to be careful what you pick if you want all your text to be readable.

For example, I made a blueish/purple background with a color gradient and some other subtle effects applied by GIMP, and so my current set up looks like this:
tw.png
tw.png (206.73 KiB) Viewed 42115 times

Just thought I'd share my happiness. It's purely aesthetic of course, but it makes my day a little more pleasant.

Tags:

User avatar
localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Fri Nov 27, 2009 10:17 pm

Perhaps the TeX related blog of Joseph Wright can help you [1]. He introduced an example for such modifications. I didn't test it, but I think it's worth a look.

[1] Some TeX Developments - Background colouring in TeXworks


Thorsten
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Postby frabjous » Fri Nov 27, 2009 10:42 pm

It doesn't help solve my problem with the active line highlighting. I have it straight from the devs that that is hardcoded and can't be customized at present. But thanks for the link. It might provide help for anyone else who wants to know more about altering syntax-patterns.txt.

kondenzator
Posts: 2
Joined: Fri Nov 12, 2010 1:55 pm

Postby kondenzator » Fri Nov 12, 2010 3:03 pm

It works good, but I have a problem: after starting with
texworks.exe -stylesheet C:\mystyle.css
I get the mystyle.css opened in texworks too, and it's very annoying. I use windows xp sp2 and texworks 0.3 r670 installed with miktex 2.9. I tried a lot of combinations of quotes (like texworks.exe -stylesheet "C:\mystyle.css"), but it doesn't work. I have tried to find some information about texworks command-line arguments but I found nothing.
What can be the solution? How can I use this option to work when I simply open .tex documents? Is there any information about texworks command line arguments?
Thanks your help in advance

Denes

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Postby frabjous » Fri Nov 12, 2010 7:04 pm

I just tried with the same version on linux, and it doesn't have this problem. It must be localized to the Windows version. You should post something about it (searching beforehand to see if it's already been logged) at the TeXworks Issue Tracker at Google Code.

kondenzator
Posts: 2
Joined: Fri Nov 12, 2010 1:55 pm

Postby kondenzator » Fri Nov 12, 2010 9:17 pm

Thanks your reply. There is an issue about this trick:

http://code.google.com/p/texworks/issues/detail?id=164

I posted this problem there too.

ajgosain
Posts: 1
Joined: Fri Apr 27, 2012 1:44 pm

Postby ajgosain » Fri Apr 27, 2012 1:49 pm

Hi there, I was hoping someone could help me do this step:
frabjous wrote:You then need to run TeXworks with the command:
  1. texworks -stylesheet /pathto/mystyle.css

I have no real programming experiencing, so I have no idea how to do this. I have created the "mystyle.css" file though.


Cheers, AJ

kumbu
Posts: 1
Joined: Thu Jun 07, 2012 6:11 pm

Postby kumbu » Thu Jun 07, 2012 6:46 pm

ajgosain wrote:Hi there, I was hoping someone could help me do this step:
frabjous wrote:You then need to run TeXworks with the command:
  1. texworks -stylesheet /pathto/mystyle.css

I have no real programming experiencing, so I have no idea how to do this. I have created the "mystyle.css" file though.


Cheers, AJ

If you run a Windows OS, open the start menu and in the 'search programs and files' text box, enter 'command prompt' and run program appearing in the list. In the new command line window, write :
  1. texworks -stylesheet C:\the_path_to_your_css_file\your_file.css

Unfortunately, it seems like it will open the CSS file in TeXworks as well as starting the application with the CSS file specifications, as reported by kondenzator earlier.

Also, if you do not want to do this every time you open TeXworks, here is how to proceed:

  1. Create a TeXworks shortcut and put it anywhere you like
  2. Close every running TeXworks windows (not sure it is necessary)
  3. Right click on the shortcut and select "Properties" from the menu.
  4. In the text box next to "Target" add this line after the text that is already in the text box:
    1. -stylesheet C:\the_path_to_your_css_file\your_file.css


    *Notice that the white spaces before and after '-stylesheet' are important
  5. Press OK and there you go! Your shortcut should launch TeXworks with the specifications contained in your CSS file.

P.S. Sorry for the syntax, English is not my first language.

Jethro Bodeine
Posts: 2
Joined: Sun Jul 15, 2012 4:31 am

Postby Jethro Bodeine » Sun Jul 15, 2012 4:54 am

I created a file "rjscolorscheme.css" and the command
  1. $ texworks -stylesheet rjscolorscheme.css file.tex

works just as you said, except for one thing (*). The syntax highlighting, as defined in "syntax-patterns.txt", is not present. This is not a problem with bad color choices - the command (*) is not looking for the file "syntax-patterns.txt".
  1. $ texworks --help

is no help, it doesn't even list the "-stylesheet" option used in (*). Hope you can help me. I'd like to spice up my TeXworks a bit.

Thanks for a really great post - J :) ethro

bootcut
Posts: 6
Joined: Fri Mar 02, 2012 6:07 pm

Postby bootcut » Thu Jan 10, 2013 5:48 pm

The 0.4 texworks release states
made the “Highlight current line” color palette-aware to accommodate dark themes and improve accessibility


How do I actually alter this? I've got the css file with the background and text color set in the css file, but I cannot find anything that tells me how to change the current line highlighting color.

I've been trying to read up on Qt, but I just can't make heads or tails of this.

Also, can I change colors of the tags window using the css file?

Thanks a bunch, this thread has been great to almost get my color scheme how I want.


Return to “TeXworks”

Who is online

Users browsing this forum: No registered users and 1 guest