How to create interlinear gloss in R markdown?

瘦欲@ 提交于 2020-06-25 05:40:06

问题


I would like to create an interlinear gloss in R markdown, in which glosses are aligned with the words that they are providing information about.

In the following example, I want the left edge of each character string in the German sentence on top to be aligned with the left edge of each character string of the English beneath it:

  1. Ich habe den Bub gesehen

    1sg.NOM have.1sg.PRES DEF.ACC.SG boy.ACC.SG see.PERF.PART

So the left edge of "boy.ACC.SG" should be aligned right beneath the left edge of "Bub."

Packages like gb4e do this in TeX, but I don't know how to align text this way in markdown.


回答1:


There are some pandoc filters available that might actually help, e.g. pangloss, which is python-based and can be installed via pip. To use it in an rmarkdown document, specify in yaml that pangloss should be used as a filter:

---
title: My title
author: Somebody
output:
  pdf_document: 
    pandoc_args:
      - --filter
      - pangloss
---

Pangloss actually seems to use the gb4e package for pdf outputting, so you may have to include it in your preamble, so that the whole thing becomes

---
title: My title
author: Somebody
output:
  pdf_document: 
    pandoc_args:
      - --filter
      - pangloss
    includes:
        in_header: add_to_preamble.tex
---

and add_to_preamble.tex must contain the line

\usepackage{gb4e}

The actual examples are included in markdown the following way (this is the example given at pangloss's github page)

As you can see in the following examples, pangloss is really easy to use:

(@) Jorge  llama             a  Maria.
    George calls-3s.PRES.IND to Maria
    'George calls Maria.'
(@ex-french) Aussi, vous pouvez          avoir    de multiples   exemples.
    also   you  can-2p.PRES.IND have.INF of multiple-PL example-PL
    'You can also have multiple examples.'

You can even refer to examples, as in (@ex-french).

This seems to be pretty much still a work in progress, though.



来源:https://stackoverflow.com/questions/46383603/how-to-create-interlinear-gloss-in-r-markdown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!