Search:   Help

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

UseDrawioFilesDirectlyInLyX

Categories: Tips
<< | Page list | >>

How to use an external template to include draw.io files in LyX.

Table of contents (hide)

  1.   1.  Description
  2.   2.  Preparation
    1.   2.1  Install an external template
    2.   2.2  Add a file format
    3.   2.3  Add a converter
  3.   3.  Insert a draw.io file
  4.   4.  Edit
  5.   5.  Categories

1.  Description

draw.io(approve sites) is a free, open-source, and secure web-based diagramming software used to create flowcharts, network diagrams, UML, and organizational charts. It operates in browsers or as a desktop app. This page explains the way to integrate LyX with a desktop version of draw.io which can be downloaded from here.

2.  Preparation

2.1  Install an external template

Open an editor to fill in the following contents and save it as UserDir/xtemplates/draw.io.xtemplate.


#
# Draw.io External Template
#
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.
#
# author Koji Yokota
#
# Full author contact details are available in file CREDITS.


Template Draw.io
	GuiName "Draw.io diagram"
	HelpText
		Draw.io diagram.
		Draw.io provided as a browser-based and also as a stand-alone application.
		This template uses a stand-alone program so please make it ready before using this template.
		Included file will be cropped to the size of the diagram.
	HelpTextEnd
	InputFormat drawio
	FileFilter "*.drawio"
	AutomaticProduction true
	# LyX has hard-coded support for these transformations
	Transform Rotate
	Transform Resize
	Transform Clip
	Transform Extra
	Preview Graphics
	Format LaTeX
		TransformOption Rotate RotationLatexOption
		TransformOption Resize ResizeLatexOption
		TransformOption Clip   ClipLatexOption
		TransformOption Extra  ExtraOption
		Option Arg "[$$Extra,$$Rotate,$$Resize,$$Clip]"
		# This string is what is output to the LaTeX file.
		Product "\\includegraphics$$Arg{$$AbsOrRelPathMaster$$Basename}"
		UpdateFormat pdf6
		UpdateResult "$$AbsPath$$Basename.pdf"
		Requirement "graphicx"
		ReferencedFile latex "$$AbsPath$$Basename.pdf"
		ReferencedFile dvi   "$$AbsPath$$Basename.pdf"
	FormatEnd
	Format PDFLaTeX
		TransformOption Rotate RotationLatexOption
		TransformOption Resize ResizeLatexOption
		TransformOption Clip   ClipLatexOption
		TransformOption Extra  ExtraOption
		Option Arg "[$$Extra,$$Rotate,$$Resize,$$Clip]"
		Product "\\includegraphics$$Arg{$$AbsOrRelPathMaster$$Basename}"
		UpdateFormat pdf6
		UpdateResult "$$AbsPath$$Basename.pdf"
		Requirement "graphicx"
		ReferencedFile pdflatex "$$AbsPath$$Basename.pdf"
	FormatEnd
	Format Ascii
		Product "[Draw.io: $$FName]"
	FormatEnd
	Format DocBook
		Product "<graphic fileref=\"$$AbsOrRelPathMaster$$Basename.png\"></graphic>"
		UpdateFormat eps
		UpdateResult "$$AbsPath$$Basename.png"
		ReferencedFile docbook     "$$AbsPath$$Basename.png"
		ReferencedFile docbook-xml "$$AbsPath$$Basename.png"
	FormatEnd
	Format XHTML
		Product "<img src=\"$$AbsOrRelPathMaster$$Basename.svg\" />"
		UpdateFormat svg
		UpdateResult "$$AbsPath$$Basename.svg"
		ReferencedFile xhtml "$$AbsPath$$Basename.svg"
	FormatEnd
TemplateEnd

2.2  Add a file format

  1. In LyX settings -> File process -> File format, press New button.
  2. Fill in the following entries:
Format: Draw.io
Short name: drawio
Extension: drawio
MIME: application/x-draw.io-diagram

2.3  Add a converter

  1. In LyX settings -> File process -> Converters,
  2. choose Draw.io as the original source,
  3. choose PDF (Graphics) as the target,
  4. fill in the Converter as "/Applications/draw.io.app/Contents/MacOS/draw.io" -xf pdf -o $$o --crop $$I
  5. and press Add button.

3.  Insert a draw.io file

  1. In a LyX file, use Insert->File->External Materials menu.
    1. Choose the draw.io file you want to insert from the Browse... button. It means you need to create a draw.io file using the draw.io app at least for the first time.
    2. Select "Draw.io diagram" from the dropdown menu of Template.
    3. Press OK button.
  2. The draw.io file is inserted in LyX. If you didn't enable Draft check button in the previous step, the preview of draw.io file will shown on screen.

4.  Edit

  • By right-clicking the draw.io image, a context menu pops up. By choosing Edit externally, you can edit the original draw.io file using draw.io app.
  • By selecting Settings in the context menu, you can change its settings such as size, crop and rotation.

5.  Categories

Tips

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2026-02-22 15:57 UTC