On 19/04/2020 6:36 am, Richard Kimberly Heck wrote:
On 4/18/20 9:49 AM, Gaston Gloesener wrote:

InsetLayout "Flex:projectNameInset"

  LabelString “My Project Name"

  LatexType Command

  LaTexName projectName

  LyxType "custom"

  Decoration Classic

  Preamble

    \newcommand*{\projectName}{ My Project Name }

  EndPreamble

End

The problem with this InsetLayout is that LyX always displays a red parameter input box after the insert of the inset and this is quite annoying in this use case as such insets will be quite common in the document. Is there any method for removing this as this macro does not require any arguments. I tried to set LatexType to None with no success and did not identify any other potential solution. Also google did not show me any potential solutions for this.

After some research and looking up in files provided with LyX I seem to understand that basically insets are always expected to have some type of conments and the use I make of it here is more a work-a-round than a solution. At least I was unable to locate an inset where no content was excpected.

So the question remains:

  * Is there a way to prevent LyX from asking for some content (red box)
  * If not, is there another solutioin than the one used here to
    achieve the same goals and avoid that input box ?
  * would it be possible to add an attribute to InsetLayout to
    disable the contents box in the doc text in a future version ?
    (like NoContent)

This is bug #4066: https://www.lyx.org/trac/ticket/4066. There's at least some intention to try to figure it out before 2.4.0. For now, the workaround you mention is the only one available.

Riki

But you can eliminate the red box from showing by closing the inset (click on the inset label to toggle open/closed).

Alternatively, there is a hybrid Latex/LyX solution, that avoids going to the menu to insert custom insets and uses keyboard shortcuts instead.

1. Ensure instant preview is On (Tools > Preferences > Look & Feel > Display)

2. Assign a keyboard shortcut to preview-insert (Tools > Preferences > Editing > Shortcuts > Cursor, Mouse and Editing Functions). Now that printing directly from LyX is no longer supported the shortcut Ctrl+P is available.

3. Enter in the preamble (Document > Settings > Latex Preamble)

\newcommand*{\projectName}{ My Project Name }

and click OK.

To enter the project name in the document,

4. insert a preview inset (Ctrl+P)

5. insert an ert inset (Ctrl+L) inside the preview inset. On a QWERTY keyboard, the P and L  keys are diagonal neighbours so steps 4 & 5 involve holding the ctrl key down and tapping P and L in quick succession.

6. enter \projectName in the ert inset

7. move the cursor outside the insets. The preview does its magic and the project name is shown.

Andrew


-- 
lyx-users mailing list
lyx-users@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-users

Reply via email to