9

For example, if I type "this" into LyX file, the output PDF will show “this”, the quotes change to a set of curly quotes. But I want it looks like "this".

Especially in LyX, there are six quotes styles:

  • “this”
  • ”this”
  • „this“
  • „this”
  • «this»
  • »this«

But none of them is the normal type, "this".

Moreover, if I paste the quotes, “”, into another TeX file, the output characters may become garbled code, e.g., âĂIJâĂİ.

It really puzzled me.

How can I obtain the quotes as " when input "?

Thanks very much!

P.S. Add a statement by @JimOldfieldJi about the difference between this question and How to get straight quotation marks? :

Reason why not a duplicate: LyX escapes characters / turns them into commands automatically e.g. typing – will output \textendash{} in the LaTeX. So this question is not about which command to use, but just how to enter a literal plain old quote character into LyX.

15
  • 1
    Welcome to TeX.SX! There is also the related: tex.stackexchange.com/q/52529 and tex.stackexchange.com/q/43561
    – LaRiFaRi
    Commented Jan 14, 2015 at 9:44
  • 2
    I wonder if the LyX aspect means this isn't a dupe?
    – Joseph Wright
    Commented Jan 14, 2015 at 9:47
  • 1
    This is definitely not a duplicate. Can someone unlock this so I can give the correct answer please? Commented Jan 15, 2015 at 6:52
  • 1
    Short answer in comment for now: Type " in a plain text editor (e.g. notepad) and copy from there and paste into LyX. Once you have one in LyX you can copy and paste that. If you do it a lot, set up a shortcut key with the function: unicode-insert 0x0022 Commented Jan 15, 2015 at 7:25
  • 3
    Reason why not a duplicate: LyX escapes characters / turns them into commands automatically e.g. typing – will output \textendash{} in the LaTeX. So this question is not about which command to use, but just how to enter a literal plain old quote character into LyX. Commented Jan 15, 2015 at 7:27

5 Answers 5

5

(Copied here from my comments, with some additions.)

LyX automatically escapes things before passing them to LaTeX. For example, – is replaced by \textendash, $ is replaced by \$, and indeed " is replaced by \textquotedbl. LyX also takes care of which packages to load and encoding to use (but isn't perfect). So the concern here is not which macro to use but just how to enter a straight quote " without LyX automatically converting it into open and close quotes “”.

There are several ways to do this:

  • The simplest is to type " into any text editor (e.g. Notepad in Windows) and copy it from there and paste into LyX. Once you've done that once you can copy it straight from LyX and paste into another part of the document.
  • Depending on your operating system, you can use the system for entering Unicode characters. On Windows this means holding the Alt key and typing the digits 034 on the numeric keypad.
  • If you need this a lot you can set up a keyboard shortcut. You can do this in the preference dialogue box under the shortcuts page, and in the add shortcut dialogue box type this function: unicode-insert 0x0022

Addendum (possibly the answer to the question you should have asked): You mentioned that copying from LyX and pasting to a LaTeX editor sometimes gives garbled output. But as I already said, the text in LyX is not LaTeX. It just shows $ instead of \$, " instead of \textquotedbl etc, and this is what is copied to the clipboard too. (Math is copied as LaTeX, but this is really the exception.) If you want to get LaTeX out of LyX, export a LaTeX file (in the file menu) or open the LaTeX source pane (using the view menu) and copy from there. Then copying even “proper quotes” will give you valid LaTeX.

1
  • Perfect answer! I think this is the most appropriate solution by now. Thank you again:)
    – Andnot
    Commented Jan 16, 2015 at 1:56
5

For single straight quotes, use Ctrl+'; for double straight quotes use Ctrl+".

7
  • ctl-" (key in Ctrl+Shift+') cannot input " in LyX (ver.2.1.2). Both ctl-' and ctl-" can only input single curly quote, . How did you do that? Thank you.
    – Andnot
    Commented Jan 16, 2015 at 2:13
  • 1
    I'm also using version 2.1.2. Check you key mappings in Preferences dialog, see Editing->Shortcuts. It could be that ' and " key combinations are being assigned to something else. In mine quote-insert maps to " and quote-insert-single maps to '. I do not have any mapping for ctrl-' or ctrl-shift-'
    – Nigel
    Commented Jan 16, 2015 at 2:21
  • 1
    @ChrisS, how did you add the key stroke symbols, please?
    – Nigel
    Commented Jan 16, 2015 at 2:21
  • 1
    I believe self-insert is used to insert keystrokes into the LyX window. If you can't find it in the editor, try looking in your bind file. You could also add the setting at the end of your bind file so it overrides any other definition. See wiki.lyx.org/Tips/KeyboardShortcuts,
    – Nigel
    Commented Jan 16, 2015 at 7:51
  • 1
    @penguinpreferred Keycaps are formatted with the HTML tags <kbd> </kbd>.
    – ChrisS
    Commented Jan 16, 2015 at 11:27
4

Without dealing with external programs, LaTeX code or shortcuts of Preferences menu:

Method 1: From menu

Menu Insert > Special character > Symbol > Category Basic Latin > " > Apply

Method 2: Copy from math mode

Ctrl+M (math mode)

⇧ Shift+2 (type " in math mode, i.e.: $"$)

⇧ Shift + <- (select ")

Ctrl + C (copy ")

(out of math mode)

Backspace (remove $"$)

Ctrl + V (paste " in tex mode, i.e.:\textquotedbl{})

As Annot point, using another language than English, the result could be an annoyng underlined symbol that is translated to LaTeX as \foreignlanguage{english}{\textquotedbl{}}

Method 3: Copy from a ERT box. Similar to the above, but without side effects.

Ctrl+L (Evil Red Text mode)

⇧ Shift+2 (type " in plain text)

(If you do not mind see the symbol in ERT boxes, this is enough, but I am afraid that this could be a source of problem at least if you are using babel shorthands.)

⇧ Shift + <- (select ")

Ctrl + C (copy ")

(out of ERT box)

Backspace (remove ["])

Ctrl + V (paste " in tex mode, i.e.:\textquotedbl{})

In this case, as far I see this not produce a \foreignlanguage command.

Method 4: Keyboard shortcuts. In Linux with a Spanish keyboard (probably not the same that other keyboard layouts):

Ctrl + ⇧ Shift + "2@ ...or ...

⇧ Shift + ¨´{ + space

2
  • Copy from math mode may generate extra code of language package, e.g. \foreignlanguage{english}{\textquotedbl{}}.
    – Andnot
    Commented Jan 16, 2015 at 9:00
  • 1
    @Annot Yes. Typical annoying garbage cost of this front-end, but you can do the same with a ERT without this problem. I will update de answer.
    – Fran
    Commented Jan 16, 2015 at 9:38
3

A simpler solution:

Remove both the shortcuts of quote-insert and quote-insert-single in Preferences.

And now you can input these two kinds of straight quotes just by key in ' and " directly.

Thanks for the hints of @penguinpreferred

2
  • 1
    Yes, but I believe keeping the shortcuts allows entering of typsetting quotes which LyX then adjusts according to its settings.
    – Nigel
    Commented Jan 17, 2015 at 7:05
  • 1
    this must be the accepted answer, and instead of deleting the shortcuts you can just swap them
    – gevra
    Commented Apr 2, 2019 at 10:16
2

You could use the macro \textquotedbl, which requires loading the fontenc package with an option such as T1.

\documentclass{article}
\usepackage[T1]{fontenc}
\begin{document}
\textquotedbl this\textquotedbl
\end{document}
3
  • Thank you for your answer! But key in \textquotedbl every time is a little bit troublesome. Is there a simpler solution?
    – Andnot
    Commented Jan 14, 2015 at 10:15
  • 1
    @Andnot - If your use case consists of words that need to be surrounded by "straight" double-quote marks on both sides, you could define a macro named \dq -- e.g., \newcommand{\dq}[1]{\textquotedbl#1\textquotedbl} -- in the preamble and write \dq{this} in the body of the document.
    – Mico
    Commented Jan 14, 2015 at 10:38
  • Oh, that's definitely useful~ Thank you very much!
    – Andnot
    Commented Jan 14, 2015 at 13:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .