Edit Links |
LyX /
LinguistLyX
<< | Page list | >>
Using LyX for Linguistic Papersby Maria Gouskova, Stacia Hartleben and Jürgen Spitzmüller
LyX and LinguisticsLinguists, as opposed to, say mathematicians, have diverse and specific typographic needs, such as:
LyX serves these needs pretty well, even if some of the tasks remain difficult. This site documents LyX's linguistic features and shows some workarounds and feature requests for future LyX versions. For general information about using LyX in humanities, which covers a lot of linguists' needs as well, consult the site HumanitiesLyX. For general information on LaTeX for linguists please see Doug Arnold's LaTeX for linguists page, the UPenn LaTeX page, and Ling-TeX. LyX for Linguists Linguistics Module [new in 1.6]LyX 1.6 introduces the feature of modules that add specific features to your document. It ships a Linguistics module that adds some native support for numbered examples, glosses, OT tableaux and some semantic markup. You can load the module in Document→Settings→Modules. Instructions for this module can be found throughout this site. Additionally, LyX 1.6 also includes a small manual that demonstrates the features (cf. Help→Specific Manuals→Linguistics Manual). If you have suggestions for features that could be added to this module, don't hesitate to contact the LyX developers list. Phonology/PhoneticsUsing LyX to Display Phonetic Characters (IPA)Beginning with Version 1.5.0, LyX has switched to Unicode. If you are used to working with Unicode fonts such as the SIL Doulos IPA font, you can principally continue entering International Phonetic Alphabet (IPA) symbols in the same way you usually do (for example, using a Keyboard Layout). You can also copy and paste Unicode IPA text from other sources into LyX or insert them via Insert→Special Characters→Symbols.... Such "direct" Unicode input is particularly advised if you're using XeTeX or LuaTeX with "non-TeX fonts". With this specific setting, there's even no other way to enter IPA (up to LyX 2.0). That's not a problem. You just have to take care to select a font that includes the IPA glyphs, and everything should just work. However, in all other settings (i.e., with "TeX fonts", be it with XeTeX/LuaTeX or traditional LaTeX), direct input has several drawbacks. Read the following section a.), if you are interested in details and technical reasons. If you believe us and/or want to insert good-looking IPA without further ado, just hop to section b.) below. a.) Drawbacks of direct Unicode input with "TeX fonts" and advantages of the dedicated IPA inset First, outside XeTeX/LuaTeX, not all IPA symbols are known by LyX yet, If you enter such an unknown symbol, LyX will yield an error message. In this case, find out the UCS4 code point, look up the command name in the TIPA manual, and add a line to the file Second, if you enter Unicode symbols directly (again, with "TeX fonts"), LyX will take the "normal" (ASCII) characters from your document's main font, the IPA characters from the IPA font. This will most likely look odd. Third, native insertion of Unicode glyphs results in sub-optimally kerned words (i.e., bad spacing between letters). This is due to the way LyX resolves these glyphs to LaTeX (see below for the technical explanation). LyX's native IPA support via the dedicated IPA inset cures these issues. Here's why. If "TeX fonts" are used, IPA symbols are produced by means of the TIPA package, LaTeX's standard package for IPA support. This package includes two font families. One has been designed to be used with LaTeX's computer modern family of fonts, the other with times (i.e. mathptmx.sty). Please refer to the voluminous TIPA manual for details. So if you insert a Schwa glyph, LyX will automatically convert this glyph to the respective TIPA macro (\textschwa). LaTeX then typesets the Schwa glyph from the TIPA font. If you insert a normal alphabet glyph (such as b), it will be passed to LaTeX literally, however, so LaTeX typesets the b not from the IPA font, but from the main text font, whatever that may be. LyX's dedicated IPA inset, however, assures that all text uses the IPA font. This cures the font mixing problem. Also, with the dedicated inset, you can additionally use the handy "TIPA shortcut notation" (see below), which is in fact faster than Unicode input, once you are used to it. Moreover, the kerning problems described above do not occur with the shortcut notation. Here's the technical explanation: When LyX exports the Unicode glyphs to TIPA macros (such as \textschwa), it terminated those macros by braces (i.e., \textschwa{}). LyX does this in order to prevent LaTeX errors. Think of a Schwa followed by a b. Without the braces, this would result in \textschwab (instead of \textschwa{}b), and this would confuse LaTeX, because the command \textschwab does not exist. These braces, however, disturb the kerning. The correct solution would be a blank, i.e. \textschwa b, but this requires a much more complex algorithm (In fact, LyX 2.1 will follow this more complex algorithm and thus fix the kerning problems). So much for technical details. The following sections describe how to use LyX's dedicated IPA inset. b.) Entering the IPA inset via the Menu The easiest way to start IPA mode is to use the menu entry Insert→Special Characters→Phonetic Symbols, which will bring you to the IPA mode immediately (this menu entry was introduced in LyX 1.4.3). You can now enter text, using the shortcut characters that TIPA provides (see the appendix of the TIPA manual for a list of all symbols and the corresponding shortcuts): That's all. If the TIPA package has been installed correctly, this text will come out as phonetic notation in the DVI or PDF output. Moreover, as long as LyX's Instant Preview feature is enabled, LyX will display the phonetic text inside LyX as soon as the cursor leaves the math inset. Voilà: As of LyX 2.0, you can also input or paste Unicode IPA glyphs into the IPA inset. LyX will automatically export them to the correct macros in the output, and no font mixing will occur. Note though, that this has the kerning drawbacks described above. c.) Inserting the IPA inset manually Alternatively, you can start IPA mode as follows. First switch to math mode. This is done by the keyboard shortcut To switch to TIPA mode, insert \textipa into this math inset and hit the space key. The \textipa will disappear and everything looks as before, but LyX is now in TIPA mode. Now enter the text as described in the previous section. d.) Converting from text to math mode You can also insert it this way: write e.) If everything else fails: Using ERT Finally, you can use LyX's LaTeX mode (ERT) to enter any TIPA command. This might be necessary sometimes to use things that are not yet supported. Of course, you'll lose all the nice features of the native support, most notably Instant Preview. f.) Perspectives: an improved IPA inset Forthcoming LyX 2.1 (currently still in an early development stage) will feature a new IPA inset, which does not rely on the math editor and which will fix some of the shortcomings of the current IPA inset. Watch out for details here. Tables and Optimality-Theoretic TableauxUnlike some LaTeX editors, LyX allows you to edit tables visually, though its table formatting capabilities are somewhat limited. The most important OT-specific table formatting need is dashed vertical lines--the typical way of showing that two constraints cannot be ranked with respect to each other based on available evidence. Dashed lines are created using the package arydshln. Another need, which is formally somewhat superfluous(approve sites), is table cell shading--the way to show the violations that are irrelevant to the fate of a candidate. See the LyX wiki page Tables for dashed lines and shading. Here are some examples of tableaux: comparative_tableau_example.lyx Tableaux Floats and List of Tableaux: [new in 1.6] The Linguistics Module provides a separate float for Tableaux as well as a List of Tableaux (with a separate counter). You can find and use both the same way as table and figure floats. Note that the captions are always below the tableau by default, no matter where you put them in the LyX view. To get captions on top, put in preamble \floatstyle{plaintop} \restylefloat{tableau} If your using a KOMA class and the option "tablecaptionsabove", use the following instead for better spacing: \floatstyle{komaabove} \restylefloat{tableau} For LyX < 1.6, you have to create such a float yourself. The procedure is explained in this message to lyx-users. Feature Matrices/Stuff in BracketsFor SPE-style feature representations in brackets, go to the Math Panel (Insert→Math→Math Panel) and click on the button to open the delimitor and bracket dialog. Select square brackets from the many available options, and then click on the "insert matrix" button to insert a matrix (basically, a mini-table without grid marks) inside the brackets. You can specify the number of rows and columns inside the matrix in the emerging dialog box. If you need to use the pound sign, #, inside math mode, you must type it in as \#, otherwise LyX will not recognize it as a valid character. If you want the text inside the matrix to not appear in italics, select the line and change it to text mode (see above). Other Special Characters and DiacriticsThe Comprehensive LaTeX symbol list by Scott Pakin covers many of the symbols that can be produced with LaTeX. You can insert them in LyX by means of ERT or in math-text mode as described above. Furthermore, LyX supports the direct input of unicode characters as of version 1.5.0 and automatically translates these glyphs to the according LaTeX macro on output (almost the complete list of Pakin and more should be supported). For example, an acute accent on an "a" can be entered
[new in 1.6] LyX 1.6.0 will introduce a general symbols dialog (Insert→Special Characters→Symbols...) from which you can directly insert all supported characters (cf. http://wiki.lyx.org/LyX/NewInLyX16#symbolsdialog) Symbols such as arrows, zero, relations of domination, relative harmony, and so on can be found in the Math Panel. If you need to place a primary/secondary stress (grave/acute accent) or an unstressed/short mark on top of a Greek letter, the easiest way is the Math Panel/Frame Decorations. If you need a pointy hand to mark the winner in your OT tableau, there are several options available in various packages. The bbding package has a nice pointy hand with a cuff, which in ERT is entered as Using LyX to Draw TreesPackagesOne of the following packages is needed to draw trees in LyX:
The choice of the package depends on your needs and taste. Here are some pros and cons:
Simple Trees with qTreeInstall the qTree package and then put \usepackage{qtree} into your preamble. Make sure that Instant Preview is activated. Then hit \Tree[.S [.N This ] [.V is ] [.NP [.Det a ] [.N test ] ] ]
After the cursor has left the inset, the tree should be displayed inside LyX: Alternatively, you can again write the text outside math mode, select it, and hit If the branches of the tree vanish in your preview, you are facing a bug in dvipng, the converter used by Instant Preview to generate the preview images for LyX. The bug has been reported to the dvipng developer and he has fixed it for the upcoming version 2.0 of dvipng. So watch out for dvipng >= 2.0 and upgrade to that. Roofs Roofs (for complex phrases) can be inserted with the There you can type the phrase inside this subinset, which is then marked as follows. Here's the Instant Preview display after the cursor left the inset: Glosses To put glosses under the nodes of a tree, you have to fool the Math Editor. In qtree, this can be done with the linebreak command \renewcommand{\breaknode}{\\}
Then you can do: \Tree[.S [.N Das\breaknode This ] [.V ist\breaknode is ] [.NP [.Det ein\breaknode a ] [.N Versuch\breaknode test ] ] ]
This also works inside qroofs. Prosodic Structure Trees/Greek Symbols in TreesIf you want to include greek letters such as sigma for syllable nodes or mu for morae, you have to enter math-math mode while keeping the tree in math-text mode. The greek symbols must then be entered in LaTeX code, which requires putting them between dollar signs, as in: \Tree [.$\sigma$ $\mu$ $\mu$ ]
Instead of manually inserting the dollar signs, you can also switch to math-math mode before entering the Greek letters by pressing again This will produce a simple syllable (sigma) branching into two moras (mu), viewable via Instant Preview inside LyX. Autosegmental treesFor simple feature-sharing trees, \Tree {\K{[back]} \B{d}\Bdash{dr} \\ \K{V} & \K{V}}
\Tree{\K{[back]} \D\Bdash{dr}\Bdash{drr} \\ \K{V} & \K{V} & \K{V}\B{d} \\ & & \K{[-low]}}
To do autosegmental delinking, you need "Right-side-up" trees, lattices, OT Hasse trees (ranking diagrams)The package Using LyX to display numbered examples with CovingtonThe package Covington does several useful things, but one of its most convenient functions is that it provides a sequentially numbered environment that can span several sections. Your numbered examples will look as follows: The package provides the environments Setting LyX up to include a Covington environmentIf you use numbered examples a lot, you can also make the Covington numbered environment available in your document as a separate paragraph environment similar to [new in 1.6] As of LyX 1.6, doing this is easy. Just load the Linguistics Module and you will find styles for For versions older than 1.6, there are two ways to achieve the same (the first one is easier):
All these methods will make every Covington-numbered example display in blue font but without a number; the document will typeset in a normal way and you can cross-reference Covington-numbered examples in the text as usual (by inserting label). This is how your screen will look for the Covington example above: Adjusting Covington ExamplesCovington's example style is aimed at typical use, which means that it needs to be adjusted for specific uses. Here are some advices how to do that in Q/A form.
Place [(whatever)] in TeX mode at the very beginning of the subexample.
Covington has a fixed indendation that fits well if the example number is not too large. However, with more than 99 examples or if you use a book class, where covington numbers chapterwise [e.g. (1.10)], the indendation looks odd especially for multi-line examples. You can adjust the indendation with the following preamble code (adjust the values if needed):
\let\oldexamples\examples
\let\endoldexamples\endexamples
\renewenvironment{examples}{%
\setlength\leftmargini{3.05em}
\begin{oldexamples}%
\settowidth{\labelwidth}{(0.00)}}
{\end{oldexamples}}
\renewenvironment{example}{%
\setlength\leftmargini{3.05em}
\begin{examples}%
\settowidth{\labelwidth}{(0.00)}%
\item}
{\end{examples}}
Covington (mis)uses LaTeX's equation counter, so you need to adjust this counter in your preamble as follows:
% use package remreset to omit counter resetting on new chapter
\usepackage{remreset}
\@removefromreset{equation}{chapter}
% redefine equation counter (do not prepend chapter number)
\renewcommand{\theequation}{\arabic{equation}}
If you just want to omit the chapter prefix and still want to have the examples start from (1) at each chapter start, just use the last two lines of the code.
Aligned Glosses (Covington)Often linguists need to have a list of examples which are glossed word by word. A great package for this is, again, Covington. [new in 1.6] The Linguistics Module shipped with LyX 1.6 provides some native support for covington glosses, even though you still need some LaTeX syntax. After you have loaded the module, you will find two insets "Glosse" and "Tri-Glosse" in Insert→Custom Insets. The following screenshot shows how a sentence and its glossed translation are input into the inset, just as two consecutive lines (for Tri-Glosse, that would obviously be three). The last line is the (mandatory) (grammatically well-formed) translation which must be preceded by \glt (not in ERT, just verbatim): The PDF output of the example looks as follows: In LyX 1.5 and earlier, you will have to stick to ERT snippets. The above example would have to be inserted in TeX mode as follows:
\begin{examples}
\item This is an example in English.
\item \gll Dit is een voorbeeldje in het Nederlands.
This is a {little example} in {} Dutch.
\glt `This is a little example in Dutch.'
\glend
\end{examples}
If you have set up LyX to support covington examples natively (as described here), you do not need the Also note that up to LyX version 1.3 you will have to separate the lines inside the ERT with a linebreak ( SemanticsMarkup[new in 1.6] The Linguistics Module that ships with LyX 1.6 provides some semantic markup for "expression" (emphasized by default), "concept" (small caps by default) and "meaning" (enquoted by single quotes by default). The definitions can be changed in the preamble. Logical SemanticsFortunately, the logical semantics notation is pretty much covered by LyX's math mode. So if you want to insert logical semantic notation, do as if you would want to insert a math formula. You'll find most of the required symbols in the Math Panel (Insert→Math→Math Panel). If you are a bit familiar with the LaTeX notation of that symbols, you can enter them directly into the formula. LyX will convert them for you. With Instant Preview enabled, you'll even get a WYSIWYG display in LyX. Other stuffThere are packages available for other semantic needs.
Conversation AnalysisIn Conversation Analysis, turns need to be aligned to mark overlaps, turn takings, etc. LyX does not allow multiple blanks and does not have a tabulator, but with LaTeX's Consider the following simple example:
\begin{tabbing}
1 \=Peter: \=Do you know [=LyX=] \=the the document\\
2 \>Mary:\>\>yeah I know
\end{tabbing}
With \= you save a position, at which \> will push the text. Note that Caveats:
If you need arrows and other symbols for your notation, you'll most likely find them in the Math Panel. If not, read this. Switching languagesTo switch languages, e.g. between English and Greek, go to Edit→Text Style→Customized...→Language and select the respective language (e.g. "Greek"). This will apply to all following text (or the selected text). If you select "reset", the language will be reset to the document's main language (as set in Document→Settings→Language). Foreign languages (i.e. those differing from the document's main language) are marked by a blue underline. If you use "aspell (library)" as spell checking backend and if the spell checking dictionaries are installed, LyX will spellcheck all marked passages in the allocated language. If you need to switch languages a lot, opening the text style dialog every time might be too clumsy. To speed up the workflow, you can define keyboard shortcuts for your common languages:
Now you can switch to English by just pressing Alt+l+e (or whatever keyboard shortcut you have defined). Note that the language function acts as a toggle. I.e., if you mark a foreign German passage of text and press Alt+l+g (for German), the language of the passage will be reset to the document's main language. Note that in older (< 1.5) versions, only one kind of writing system will be displayed inside LyX (i.e. Latin letters instead of Greek ones if the main language is English). In the PDF output, however, the correct writing systems (Roman alphabet for English, Greek alphabet for Greek) are used. As of version 1.5, LyX uses the unicode encoding internally, so it can to display Latin and Greek (and Cyrillic ...) letters in parallel. However, this is only done if the letter is keyed in as a Greek one (e.g. via a character picker, drag-and-drop from a unicode encoded source or a matching keyboard mapping). To switch between English and Russian, go to Document→Settings→Customized...→Language and set the document's language to Russian. Switch to the Cyrillic keyboard layout of your OS when you need to type in Russian, and switch back when you need English. Both Russian and English will be displayed in LyX. BibliographiesLyX has native BibTeX support for bibliographies. By default, LyX is configured to use the bibliography style A bibliography style popular among linguists is linquiry2.bst. It's designed for List of PublicationsYou can generate a list of your own publications semi-automatically, using BibTeX. See this page for details. Acknowledgment footnoteIt is common in linguistics articles to label the acknowledgment footnote (usually the first footnote) with an asterisk rather than with a regular number. To accomplish this in LaTeX, put the following in ERT: Table Symbol Tree Numbering Footnotes Humanities Linguistics |