更正: 在原文我寫道,浮動是全角顯示的。這是一個錯誤;就像用它們創建的“flexi-insets”一樣,InsetLayout
只有當它們包含多於一行時才會以全角顯示。因此,解決方法也無法如預期般運作。
在 LyX 中,有一些內建佈局,Resources/layouts/stdlayouts.inc
插入時會填滿編輯器的整個寬度。此行為適用於原型版面Box
和Box:<SpecificName>
版面系列。類似的行為也適用於浮動。
我想定義一個本地佈局,將一個段落包含在widetext
環境中。佈局
InsetLayout WideText
LyXType Custom
LabelString WideText
LatexType environment
LatexName widetext
Decoration classic
LabelFont
Color blue
Size Small
EndFont
MultiPar true
OptionalArgs 0
Preamble
\RequirePackage{widetext}
EndPreamble
End
這樣做,但在 LyX 中,插圖的顯示寬度僅與其內容一樣寬——這不能很好地反映實際環境。我希望我的插圖以盒子和浮動的樣式顯示,而不是:盒子總是包括一個小頁面環境(這是不希望的),浮動會導致前導碼發生不必要的更改,除非被駭客抑制(因此可能會在 LyX 的未來版本中中斷)。
作為解決方法,我正在使用佈局
Float
Type widetext
GuiName widetext
IsPredefined true
End
其中IsPredefine
抑制了序言中的一個條目,該條目與環境的定義相衝突widetext
。然後將插圖列在插入 → 浮動結果看起來像這樣
而編譯的行為在這兩種情況下都是正確的。
但是是否有一個乾淨的解決方案可以在不使用浮動駭客的情況下獲得所需的行為?
答案1
據我了解,這對於 Flex 插圖來說是不可能的。
查看原始碼,我們看到Inset.h有以下內容
/// Is the width forced to some value?
virtual bool hasFixedWidth() const { return false; }
在 InsetFlex 的繼承鏈中,該成員函數永遠不會被重寫。
框具有以下內容(請參閱 InsetBox.cpp):
bool InsetBox::hasFixedWidth() const
{
return !params_.width.empty();
}
如果您將 return 更改為 be return false;
,那麼它們也不會具有您正在討論的完整頁面寬度。
請注意,當我將您的定義複製/貼上到文件 > 設定 > 本地佈局時,我在終端上得到以下輸出:
insets/InsetLayout.cpp (206): Flex insets must have names of the form `Flex:<name>'.
This one has the name `WideText'
Ignoring LyXType declaration.
LyX: Unknown InsetLayout tag [around line 2 of file current token: 'Custom' context: '']
LyX: Unknown InsetLayout tag [around line 11 of file current token: 'OptionalArgs' context: '']
LyX: Unknown InsetLayout tag [around line 12 of file current token: '0' context: '']
frontends/qt4/GuiDocument.cpp (571): Format 49
InsetLayout "Flex:WideText"
LyXType Custom
LabelString WideText
LatexType environment
LatexName widetext
Decoration classic
LabelFont
Color blue
Size Small
EndFont
MultiPar true
ResetArgs 1
Preamble
\RequirePackage{widetext}
EndPreamble
ResetsFont true
End
您可能想要更正這些錯誤。
最後,請注意,我對 LyX 中的佈局缺乏經驗,因此上述任何一項都可能會關閉。您應該加入我們的郵件清單:[電子郵件受保護]並在那裡發布進一步的問題。那裡的專家比我懂得多。