10

I want to type guillemets (angle quotes, «») in Ubuntu when using

  1. Russian keyboard mapping
  2. English keyboard mapping

Is it possible (preferably without typing numeric codes)?

There is a discussion here, but it does not mention Linux.

rapt
  • 520
  • Where do you want to enter "guillemets"? In LibreOffice Writer or in TeX? – N0rbert Aug 02 '18 at 08:53
  • @N0rbert Generally in every application, if possible. I usually use LibreOffice Writer and Sublime Text. – rapt Aug 02 '18 at 09:03
  • @rapt LibreOffice convert automatically the " symbol into guillemet, so that's not a problem on this program; but for Sublime Text, I don't know – damadam Aug 02 '18 at 09:11
  • @damadam Is there a setting for that in Writer? When I try, it uses smart quotes e.g. “hello”. – rapt Aug 02 '18 at 09:16
  • @rapt What is your desktop environment? – N0rbert Aug 02 '18 at 09:16
  • @rapt Pretty sure, but I don't know which one it is or where it is, my LO is installed by default and give me guillemet when I use " (is it because I use a French keyboard layout? I don't know) – damadam Aug 02 '18 at 09:20
  • @N0rbert I use Unity desktop. – rapt Aug 05 '18 at 19:23
  • @rapt See my answer below. It suitable for many systems (including Ubuntu 16.04 with Unity). – N0rbert Aug 05 '18 at 19:34
  • @damadam I recall that in the past I indeed had these «» in Writer by default, and it was annoying since I did not usually want them instead of "" when I type in English. I do not remember if I then found how to change this behavior, but anyway now it types smart quotes by default in Writer. This is also not exactly what I wanted (i.e. dumb quotes). – rapt Aug 05 '18 at 21:13

3 Answers3

10

Below is list of methods to enable special typographic symbols.
For Russian en English layouts they are defined in /usr/share/X11/xkb/symbols/typo file (mainly based on the layout proposed by Ilya Birman).

As the result you will get the following symbols:

First keyboard row:

  • ~ NoSymbol , Shift+~ approxeq ;
  • 1 onesuperior ¹, Shift+1 exclamdown ¡;
  • 2 twosuperior ², Shift+2 onehalf ½;
  • 3 threesuperior ³, Shift+3 onethird ;
  • 4 dollar* $, Shift+4 onequarter ¼;
  • 5 U2030 (PER MILLE SIGN) , Shift+5 NoSymbol;
  • 6 uparrow , Shift+6 NoSymbol;
  • 7 ampersand &, Shift+7 questiondown ¿;
  • 8 infinity , Shift+8 oneeighth ;
  • 9 leftarrow , Shift+9 NoSymbol;
  • 0 rightarrow , Shift+0 NoSymbol;
  • - emdash , Shift+- endash ;
  • = notequal , Shift+= plusminus ±;

Second keyboard row:

  • e EuroSign , Shift+e NoSymbol;
  • r registered ®, Shift+r NoSymbol;
  • t trademark , Shift+t NoSymbol;
  • y yen ¥, Shift+y NoSymbol;
  • p acute ´, Shift+p doubleacute ˝;
  • [ bracketleft [, Shift+[ braceleft {;
  • ] bracketright ], Shift+] braceright }.

Third keyboard row:

  • a U0301 (COMBINING ACUTE ACCENT) ́, Shift+a NoSymbol;
  • s section §, Shift+s NoSymbol;
  • d degree °, Shift+d division ÷;
  • f sterling £, Shift+f NoSymbol;
  • j doublelowquotemark , Shift+j singlelowquotemark ;
  • k leftdoublequotemark , Shift+k leftsinglequotemark ;
  • l rightdoublequotemark , Shift+l rightsinglequotemark ;
  • ; leftsinglequotemark , Shift+; minutes ;
  • ' rightsinglequotemark , Shift+' seconds .

Fourth keyboard row:

  • x multiply ×, Shift+x U22C5 (DOT OPERATOR) ;
  • c copyright ©, Shift+c cent ¢;
  • v downarrow , Shift+v U25CA (LOZENGE) ;
  • m U2212 (MINUS SIGN) , Shift+m enfilledcircbullet ;
  • , guillemotleft «, Shift+, less <;
  • . guillemotright », Shift+. greater >;
  • / ellipsis , Shift+/ NoSymbol;

Space:

  • Space nobreakspace , Shift+ Space nobreakspace .

For other languages layouts may vary.
Settings for common desktop environments are presented below.


Ubuntu with Unity and GNOME desktop environments

Ubuntu 14.04 LTS and Ubuntu 16.04 LTS

  1. Launch GNOME Tweaks (installable with sudo apt-get install gnome-tweak-tool, run by gnome-tweak-tool)

    1. Go to Typing
    2. In Miscellaneous compatibility options check Enable extra typographic characters
    3. Close GNOME Tweaks.
  2. Open Keyboard preferences (or unity-control-center keyboard)

    1. Click on Text Entry, then on Keyboard Settings...
    2. Select key in Alternative Characters Key (for example, Right Alt) (note: it is 3rd level)
    3. Back to Text Entry section, select Russian keyboard layout and click small keyboard icon keyboard icon to ensure that we have guillemets («елочки»):

      Guillemets or Елочки in GNOME

    4. Close Keyboard windows.

  3. Use guillemets («елочки») in any application by pressing RightAlt with corresponding keys (Б and Ю; , and .).

Ubuntu 18.04 LTS

  1. Launch GNOME Tweaks (installable with sudo apt-get install gnome-tweaks, run by gnome-tweaks)
    1. Go to Keyboard & Mouse
    2. Click on Additional Layout Options
    3. Expand Miscellaneous compatibility options check Enable extra typographic characters
    4. Close GNOME Tweaks.
  2. Use guillemets («елочки») in any application by pressing RightAlt with corresponding keys (Б and Ю; , and .).

Ubuntu with MATE Desktop Environment (any version)

GUI way

  1. Open System -> Preferences -> Hardware -> Keyboard (or mate-keyboard-properties).
  2. Go to Layouts tab
    1. Click Options
    2. In Key to choose 3rd level choose needed key (for example Right Alt)
    3. In Miscellaneous compatibility options check Enable extra typographic characters
    4. Click Close
  3. Select Russian keyboard layout and click Show to ensure that we have guillemets («елочки»):

    Guillemets or Елочки in MATE

  4. Use guillemets («елочки») in any application by pressing RightAlt with corresponding keys (Б and Ю; , and .).

Terminal way

Use GSettings to set two layouts (us and ru) using Alt+Shift as layout switcher, typographic symbols are enabled RightAlt as 3rd level switch::

gsettings set org.mate.peripherals-keyboard-xkb.kbd layouts "['us', 'ru']"
gsettings set org.mate.peripherals-keyboard-xkb.kbd model "''"
gsettings set org.mate.peripherals-keyboard-xkb.kbd options \
"['grp\tgrp:alt_shift_toggle', 'lv3\tlv3:ralt_switch', 'compat\tmisc:typo']"

Other GUI sessions and terminal

Edit /etc/default/keyboard and add here two parameters as described in man xkeyboard-config:

  • misc:typo to enable extra typographic characters and
  • lv3:ralt_switch to choose typographic symbols with Right Alt:

    XKBOPTIONS="grp:alt_shift_toggle,lv3:ralt_switch"
    

After editing you should update initramfs images to include the new version of configuration file

sudo update-initramfs -k all -u
N0rbert
  • 99,918
  • I use the Unity desktop. I tried your "Ubuntu 14.04 LTS and Ubuntu 16.04 LTS" way and nothing happens. When I am in Russian keyboard and do AltRight+<, it prints б. – rapt Aug 05 '18 at 20:26
  • Very strange. Just tested this method again on clean Ubuntu 16.04 LTS VM with Unity desktop (followed my guide above line-by-line). With "RightAlt" + "ю" or "RightAlt" + "." it prints ». Do you see 3rd level on the image of keyboard layout chart (accessible from keyboard indicator in right top corner of the screen)? – N0rbert Aug 05 '18 at 20:48
  • I forgot mentioning: in the tweak tool the option is called "Key to choose 5th level" (not 3rd level). I used this option. What does "level" mean? You did not explain this term. Other than this I think I could follow precisely the instructions you had listed. I can open the image of keyboard layout chart, but I do not understand what you mean by "3rd level on the image"? – rapt Aug 05 '18 at 21:02
  • On 16.04 LTS 3rd level is named as Alternative Characters Key in unity-control-center keyboard. Thank you for correction! 3rd-level is next level for <Shift+key>, I think. If it is not enabled you have lowercaps and capitals. If 3rd level is enabled you have special 3rd level of typographic symbols (see MATE keyboard screenshot above - it have guillemets and other characters). Please follow my instruction precisely. I have tested it many times. Also see this page about typographic keyboard layout (Ubuntu's 3rd layout is based on it). – N0rbert Aug 05 '18 at 21:20
  • Thank you. It works now (but with a problem). Do you mean that on my system 3rd level is always enabled (available)? As I mentioned, in the tweaking tool, the only relevant option was to choose a key to enable 5th level (I am not sure what 5th level is), but nothing about 3rd level. THE PROBLEM IS that the key I choose for "Alternative Characters Key" (e.g. RightAlt) is not anymore functioning in any shortcut that includes this key. Is there a way to solve this? – rapt Aug 05 '18 at 23:47
  • I do not think this is a problem. As we enable 3rd level by RightAlt then do not use it for shortcuts starting (or containing) Alt. Use LeftAlt instead. Also you can read somewhere about layout switching on wikipedia. As we do not have hardware AltGr key, we may use one from the Alternative Characters Key list (for example RightAlt). I can't offer more. The method above is complete and working. – N0rbert Aug 06 '18 at 08:44
  • 1
    Thank you, it works, I use it. I think they could have done it better by allowing to override the 3rd level by the regular shortcuts such as the ones I have already defined. But generally it's useful to have access to the 3rd level of the keyboard. – rapt Aug 15 '18 at 22:51
  • 1
    Holy Moly! All that work, clearly formatted, pictures added and still only 1 upvote? +1 Also, you can do keyboards the hard way – Fabby Aug 16 '18 at 21:24
  • You seem to have a sense of humor. Drop by in chat sometime. We can use a few more like you. – Fabby Aug 16 '18 at 21:32
  • 1
    OMG finally the solution to all my problems (well, some of them)! guillemets and combining acute in the same layout – Guard Jun 13 '21 at 12:34
6

On the English keyboard the simplest way I have found is this...
Tap Compose then >> (2x > in succession) which gives »
Tap Compose then << (2x < in succession) which gives «

graham
  • 10,436
  • does it work with others language keyboard mapping? – damadam Aug 02 '18 at 08:24
  • Works on my English UK keyboard so US probably so but I don't have a Russian keyboard... Does the Russian keyboard have the > char? If so, I don't see a reason not to. – graham Aug 02 '18 at 08:38
  • @Graham I do not have that AltGr key in my physical Keyboard. Is there a way to work around this? Did they not take it into account? What do you mean by not having a Russian keyboard? You can add the Russian keyboard mapping, no? – rapt Aug 02 '18 at 08:57
  • The OP asked for English keyboard mapping which is what I responded to. That said, further research suggests that Ctrl-Alt is the same as AltGr on the Russian keyboard. – graham Aug 02 '18 at 09:24
  • @rapt I amended my answer to show that you can use Ctrl-Alt instead if you don't have the AltGr key. – graham Aug 02 '18 at 17:34
  • @Graham I tested Super+Ctrl+Alt+<< on both English and Russian keyboard mappings. It did not work. I am using Unity desktop. – rapt Aug 05 '18 at 19:22
  • Does not work for me too (tested on Unity and MATE 16.04 LTS). – N0rbert Aug 05 '18 at 19:35
  • @N0rbert Tap Super then release and tap Ctrl-Alt release then >> works fine for me on 16.04 LTS (don't forget that ">" is a shifted character) using an English (UK) keyboard layout so effectively, you are latching each key press. Can't answer for MATE as I don't have the platform on which to test – graham Aug 06 '18 at 11:12
  • @Graham This is strange, how could this work on Unity? When I tap Super it already invokes the Unity menu (the default behavior). – rapt Aug 08 '18 at 11:42
  • @rapt because I've set the right Windows key as the Compose Key and it is that key which I press to generate the characters. I've altered my answer to reflect that to avoid confusion but you are correct; the left Windows key is set as Super on my keyboard and that launches the Unity menu. Sorry for the confusion. I mistakenly thought that Super and Compose keys were one of the same. You can set the Compose key under System Settings> Keyboard> Shortcuts> Typing and that might help avoid confusion. – graham Aug 08 '18 at 12:33
  • 1
    @N0rbert Please see my additional response to rapt. I confused the "Super" and "Compose" key terminology. I've amended my answer accordingly. – graham Aug 08 '18 at 12:39
  • 1
    Edited to show abbreviated method using only Compose key and right/left angle brackets – graham Aug 09 '18 at 08:47
  • @GunnarHjalmarsson Done! – graham Aug 09 '18 at 09:21
  • @Graham When trying to set the Compose key, I only have the options: disabled, right alt, right ctrl, right win, left ctrl, menu, caps lock. There is no option for left win. Is there a way around this? I simply use the other keys for other combinations. – rapt Aug 15 '18 at 22:05
  • @rapt maybe because the left Win key is reserved as the Super key? – graham Aug 16 '18 at 09:08
  • This works with US or Dvorak layouts, but there is no < on the Russian keyboard layout. – gerrit Jan 01 '21 at 13:57
3

Apparently having an AltGr (Alternate Graphics) key on your keyboard where the Right Alt resides on US style keyboards is helpful for « and » simulation key strokes.

From this French article, translated by google below, it says:

  • Under X11 (GNU / Linux) :

    • AltGr w (oss variant) or AltGr z (fr variant) and AltGr x give the left and right quotation marks "and"

Further discussion can be found in Wikipedia:

AltGr (also Alt Graph, or Right Alt1) is a modifier key found on some computer keyboards and is primarily used to type characters that are unusual for the locale of the keyboard layout, such as currency symbols and accented letters. On a typical, IBM-compatible PC keyboard, the AltGr key, when present, takes the place of the right-hand Alt key. In macOS, the Option key has functions similar to the AltGr key.

There is a lot more to read in the link!