mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Support \cite command in tufte classes
This is an extra command used for sidenote citations. Since we do not provide \cite with natbib (which tufte uses) as a choice, we use the new AddToCiteEngine feature to add it. File format change. Fixes: #11150
This commit is contained in:
parent
c58b914c80
commit
98621be1ba
@ -7,6 +7,10 @@ changes happened in particular if possible. A good example would be
|
||||
|
||||
-----------------------
|
||||
|
||||
2018-05-21 Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* format incremented to 553: Support \cite command in tufte classes.
|
||||
This builds on an extension of the natbib CiteEngine by tufte.
|
||||
|
||||
2018-05-10 Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* format incremented to 552: support for float alignment
|
||||
- add buffer param \float_alignment [class|left|center|right]
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX 2.3 created this file. For more info see http://www.lyx.org/
|
||||
\lyxformat 544
|
||||
#LyX 2.4 created this file. For more info see https://www.lyx.org/
|
||||
\lyxformat 553
|
||||
\begin_document
|
||||
\begin_header
|
||||
\save_transient_properties true
|
||||
@ -10,7 +10,7 @@
|
||||
\language ngerman
|
||||
\language_package default
|
||||
\inputencoding auto
|
||||
\fontencoding global
|
||||
\fontencoding auto
|
||||
\font_roman "default" "default"
|
||||
\font_sans "helvet" "default"
|
||||
\font_typewriter "default" "default"
|
||||
@ -28,6 +28,8 @@
|
||||
\output_sync 0
|
||||
\bibtex_command bibtex
|
||||
\index_command default
|
||||
\float_placement class
|
||||
\float_alignment class
|
||||
\paperfontsize default
|
||||
\spacing single
|
||||
\use_hyperref false
|
||||
@ -43,8 +45,8 @@
|
||||
\use_package stackrel 1
|
||||
\use_package stmaryrd 1
|
||||
\use_package undertilde 1
|
||||
\cite_engine basic
|
||||
\cite_engine_type default
|
||||
\cite_engine natbib
|
||||
\cite_engine_type authoryear
|
||||
\biblio_style plain
|
||||
\use_bibtopic false
|
||||
\use_indices false
|
||||
@ -556,6 +558,8 @@ Leider ist die Zählung im \SpecialChar LyX
|
||||
|
||||
|
||||
\begin_inset Float marginfigure
|
||||
placement document
|
||||
alignment document
|
||||
wide false
|
||||
sideways false
|
||||
status open
|
||||
@ -639,6 +643,8 @@ reference "fig:Textabbildung"
|
||||
eine, die dies nicht tut (normale Gleitabbildung).
|
||||
|
||||
\begin_inset Float figure
|
||||
placement document
|
||||
alignment document
|
||||
wide true
|
||||
sideways false
|
||||
status open
|
||||
@ -708,6 +714,7 @@ name "fig:Ganzabbildung"
|
||||
\begin_layout Standard
|
||||
\begin_inset Float figure
|
||||
placement h
|
||||
alignment document
|
||||
wide false
|
||||
sideways false
|
||||
status open
|
||||
@ -802,6 +809,7 @@ formal
|
||||
\begin_layout Standard
|
||||
\begin_inset Float table
|
||||
placement ht
|
||||
alignment document
|
||||
wide false
|
||||
sideways false
|
||||
status open
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX 2.3 created this file. For more info see http://www.lyx.org/
|
||||
\lyxformat 544
|
||||
#LyX 2.4 created this file. For more info see https://www.lyx.org/
|
||||
\lyxformat 553
|
||||
\begin_document
|
||||
\begin_header
|
||||
\save_transient_properties true
|
||||
@ -10,7 +10,7 @@
|
||||
\language english
|
||||
\language_package default
|
||||
\inputencoding auto
|
||||
\fontencoding global
|
||||
\fontencoding auto
|
||||
\font_roman "default" "default"
|
||||
\font_sans "default" "default"
|
||||
\font_typewriter "default" "default"
|
||||
@ -28,6 +28,8 @@
|
||||
\output_sync 0
|
||||
\bibtex_command bibtex
|
||||
\index_command default
|
||||
\float_placement class
|
||||
\float_alignment class
|
||||
\paperfontsize default
|
||||
\spacing single
|
||||
\use_hyperref true
|
||||
@ -52,8 +54,8 @@
|
||||
\use_package stackrel 1
|
||||
\use_package stmaryrd 1
|
||||
\use_package undertilde 1
|
||||
\cite_engine basic
|
||||
\cite_engine_type default
|
||||
\cite_engine natbib
|
||||
\cite_engine_type authoryear
|
||||
\biblio_style plain
|
||||
\use_bibtopic false
|
||||
\use_indices false
|
||||
@ -367,6 +369,8 @@ Tufte uses ordinary figure floats such as the following:
|
||||
|
||||
\begin_layout Standard
|
||||
\begin_inset Float figure
|
||||
placement document
|
||||
alignment document
|
||||
wide false
|
||||
sideways false
|
||||
status open
|
||||
@ -437,6 +441,8 @@ reference "fig:margin-figure"
|
||||
|
||||
\begin_layout Standard
|
||||
\begin_inset Float marginfigure
|
||||
placement document
|
||||
alignment document
|
||||
wide false
|
||||
sideways false
|
||||
status open
|
||||
@ -563,6 +569,8 @@ reference "fig:full-width-figure"
|
||||
|
||||
\begin_layout Standard
|
||||
\begin_inset Float figure
|
||||
placement document
|
||||
alignment document
|
||||
wide true
|
||||
sideways false
|
||||
status open
|
||||
@ -928,6 +936,8 @@ Visualizing Rotation
|
||||
|
||||
\begin_layout Standard
|
||||
\begin_inset Float marginfigure
|
||||
placement document
|
||||
alignment document
|
||||
wide false
|
||||
sideways false
|
||||
status open
|
||||
@ -986,6 +996,8 @@ A graph of
|
||||
|
||||
\begin_layout Standard
|
||||
\begin_inset Float marginfigure
|
||||
placement document
|
||||
alignment document
|
||||
wide false
|
||||
sideways false
|
||||
status open
|
||||
@ -1302,6 +1314,8 @@ washer
|
||||
|
||||
\begin_layout Standard
|
||||
\begin_inset Float marginfigure
|
||||
placement document
|
||||
alignment document
|
||||
wide false
|
||||
sideways false
|
||||
status open
|
||||
@ -1417,6 +1431,8 @@ Then, by summing the volumes of all the washers between points
|
||||
\begin_layout Standard
|
||||
In the case of our quadratic drill bit::
|
||||
\begin_inset Float marginfigure
|
||||
placement document
|
||||
alignment document
|
||||
wide false
|
||||
sideways false
|
||||
status open
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX 2.3 created this file. For more info see http://www.lyx.org/
|
||||
\lyxformat 544
|
||||
#LyX 2.4 created this file. For more info see https://www.lyx.org/
|
||||
\lyxformat 553
|
||||
\begin_document
|
||||
\begin_header
|
||||
\save_transient_properties true
|
||||
@ -10,7 +10,7 @@
|
||||
\language english
|
||||
\language_package default
|
||||
\inputencoding auto
|
||||
\fontencoding global
|
||||
\fontencoding auto
|
||||
\font_roman "default" "default"
|
||||
\font_sans "helvet" "default"
|
||||
\font_typewriter "default" "default"
|
||||
@ -52,8 +52,8 @@
|
||||
\use_package stackrel 1
|
||||
\use_package stmaryrd 1
|
||||
\use_package undertilde 1
|
||||
\cite_engine basic
|
||||
\cite_engine_type default
|
||||
\cite_engine natbib
|
||||
\cite_engine_type authoryear
|
||||
\biblio_style plain
|
||||
\use_bibtopic false
|
||||
\use_indices false
|
||||
@ -554,6 +554,8 @@ Note: unfortunately, the counting inside the \SpecialChar LyX
|
||||
|
||||
|
||||
\begin_inset Float marginfigure
|
||||
placement document
|
||||
alignment document
|
||||
wide false
|
||||
sideways false
|
||||
status open
|
||||
@ -664,6 +666,8 @@ reference "fig:textfig"
|
||||
is an example of the normal figure float.
|
||||
|
||||
\begin_inset Float figure
|
||||
placement document
|
||||
alignment document
|
||||
wide true
|
||||
sideways false
|
||||
status open
|
||||
@ -740,6 +744,7 @@ name "fig:fullfig"
|
||||
\begin_layout Standard
|
||||
\begin_inset Float figure
|
||||
placement h
|
||||
alignment document
|
||||
wide false
|
||||
sideways false
|
||||
status open
|
||||
@ -834,6 +839,7 @@ formal
|
||||
\begin_layout Standard
|
||||
\begin_inset Float table
|
||||
placement ht
|
||||
alignment document
|
||||
wide false
|
||||
sideways false
|
||||
status open
|
||||
|
@ -17,6 +17,20 @@ ClassOptions
|
||||
Other nohyper
|
||||
end
|
||||
|
||||
# Tufte uses \cite for margin note citations
|
||||
AddToCiteEngine authoryear
|
||||
cite[][]
|
||||
End
|
||||
|
||||
CiteFormat authoryear
|
||||
_sidenote Sidenote
|
||||
_side sidenote
|
||||
_fullcite bibl. entry
|
||||
_bibentry Full bibliography entry.
|
||||
# "Margin: Full bibliography entry." (dialog) / "Margin: Key (bibliography entry)"
|
||||
cite {%dialog%[[%_sidenote%]][[%_side%]]}: {%dialog%[[%_bibentry%]][[{%label%[[%!fullcite%]][[%key%%!nextkey% (%_fullcite%)]]}]]}
|
||||
End
|
||||
|
||||
Style Standard
|
||||
Margin Static
|
||||
LatexType Paragraph
|
||||
|
@ -24,12 +24,13 @@ import sys, os
|
||||
|
||||
# Uncomment only what you need to import, please.
|
||||
|
||||
from parser_tools import (find_end_of_inset, find_end_of_layout, find_token, get_bool_value, get_value)
|
||||
from parser_tools import (find_end_of_inset, find_end_of_layout, find_token,
|
||||
get_bool_value, get_value, get_quoted_value)
|
||||
# del_token, del_value, del_complete_lines,
|
||||
# find_complete_lines, find_end_of,
|
||||
# find_re, find_substring, find_token_backwards,
|
||||
# get_containing_inset, get_containing_layout, get_value,
|
||||
# get_quoted_value, is_in_inset, set_bool_value
|
||||
# get_containing_inset, get_containing_layout,
|
||||
# is_in_inset, set_bool_value
|
||||
# find_tokens, find_token_exact, check_token, get_option_value
|
||||
|
||||
from lyx2lyx_tools import (put_cmd_in_ert, add_to_preamble)
|
||||
@ -281,6 +282,51 @@ def revert_floatalignment(document):
|
||||
i = j
|
||||
|
||||
|
||||
def revert_tuftecite(document):
|
||||
" Revert \cite commands in tufte classes "
|
||||
|
||||
tufte = ["tufte-book", "tufte-handout"]
|
||||
if document.textclass not in tufte:
|
||||
return
|
||||
|
||||
i = 0
|
||||
while (True):
|
||||
i = find_token(document.body, "\\begin_inset CommandInset citation", i)
|
||||
if i == -1:
|
||||
break
|
||||
j = find_end_of_inset(document.body, i)
|
||||
if j == -1:
|
||||
document.warning("Can't find end of citation inset at line %d!!" %(i))
|
||||
i += 1
|
||||
continue
|
||||
k = find_token(document.body, "LatexCommand", i, j)
|
||||
if k == -1:
|
||||
document.warning("Can't find LatexCommand for citation inset at line %d!" %(i))
|
||||
i = j + 1
|
||||
continue
|
||||
cmd = get_value(document.body, "LatexCommand", k)
|
||||
if cmd != "cite":
|
||||
i = j + 1
|
||||
continue
|
||||
pre = get_quoted_value(document.body, "before", i, j)
|
||||
post = get_quoted_value(document.body, "after", i, j)
|
||||
key = get_quoted_value(document.body, "key", i, j)
|
||||
if not key:
|
||||
document.warning("Citation inset at line %d does not have a key!" %(i))
|
||||
key = "???"
|
||||
# Replace command with ERT
|
||||
res = "\\cite"
|
||||
if pre:
|
||||
res += "[" + pre + "]"
|
||||
if post:
|
||||
res += "[" + post + "]"
|
||||
elif pre:
|
||||
res += "[]"
|
||||
res += "{" + key + "}"
|
||||
document.body[i:j+1] = put_cmd_in_ert([res])
|
||||
i = j + 1
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -294,10 +340,12 @@ convert = [
|
||||
[549, []],
|
||||
[550, [convert_fontenc]],
|
||||
[551, []],
|
||||
[552, []]
|
||||
[552, []],
|
||||
[553, []]
|
||||
]
|
||||
|
||||
revert = [
|
||||
[552, [revert_tuftecite]],
|
||||
[551, [revert_floatpclass, revert_floatalignment]],
|
||||
[550, [revert_nospellcheck]],
|
||||
[549, [revert_fontenc]],
|
||||
|
@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
|
||||
|
||||
// Do not remove the comment below, so we get merge conflict in
|
||||
// independent branches. Instead add your own.
|
||||
#define LYX_FORMAT_LYX 552 // spitz: float alignment
|
||||
#define LYX_FORMAT_TEX2LYX 552
|
||||
#define LYX_FORMAT_LYX 553 // spitz: tufte \cite
|
||||
#define LYX_FORMAT_TEX2LYX 553
|
||||
|
||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||
#ifndef _MSC_VER
|
||||
|
Loading…
Reference in New Issue
Block a user