On 15-Jan-21 9:21 PM, Joe Babb wrote:
I am trying to use Lyx to document some math and electronics and I
need to place a block diagram into my document. I can draw the
diagram in a separate program and insert the jpg into Lyx, but what
I'd rather do is draw it directly in Lyx and be able to place Greek
characters in each box.
I used to use Latex years ago and have the fourth edition of Guide to
Latex which talks about the picture environment. But I find no picture
environment in Lyx. I read on the Internet about typing an M-x
somewhere to get to insert commands directly but can't get that to
work. I keep wanting to work in the code preview pane to insert Latex
code directly but can't. Is it possible at all in Lyx to to a block
diagram?
thanks,
Joe
Normally, you can insert any LaTeX code (including picture environment)
using Ctrl-L or Insert -> TeX Code. This is called "ERT" in LyX AFAIK.
Since you want to write your code for graphics, I would recommend
Tikz/pgf for general sketches, instead of the old-school picture
environment. Of course, Some other WYSIWYG tools maybe more faster to
generate some specific graphics (e.g. the type of diagrams you want in
your document) without LaTeX coding, but I find Tikz quite powerful to
invest in.
CTAN says "PGF is a macro package for creating graphics. It is platform-
and format-independent and works together with the most important TEX
backend drivers, including pdfTEX and dvips. It comes with a
user-friendly syntax layer called TikZ"
So, inclusion of LaTeX math is straightforward in Tikz, while other
tools may need some tricks to get full benefits of LaTeX. Tikz has some
many packages, maybe one of them is good for your diagrams. Please look
at the Pgf/Tikz manual.
One recommendation here tough: Do not write your graphics code in LyX.
Generate it outside with regular LaTeX, and save your image as PDF.
Then, include the PDF into the LyX as figure. The issue with including
the graphics code in LyX is that, compilation times will get longer, and
it would be difficult to find the errors in your code as you have more
graphics and you have more text. Moreover, you will find out that the
ERT coding environment is not very user friendly as your figure gets
complicated, as it was not intended to develop code in there. I have
done this before, and I have found myself testing the code with LaTeX
outside LyX to find the errors. Therefore, LaTeX editors are better for
this purpose (e.g. TeXmaker, TeXstudio, even Notepad++).
If you want to give a try, I have attached two files: one for the
figure and the other one is for the settings. Compile sample.tex with
latex and you have your figure as PDF, ready to insert into LyX.
--
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
Please bottom-post. Start your reply here:
%\usepackage{mathptmx}
%\renewcommand{\familydefault}{\rmdefault}
%\usepackage[T1]{fontenc}
%\usepackage[latin9]{inputenc}
\usepackage{siunitx}
\usepackage{array}
\usepackage{amsmath}
\usepackage{ifthen}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\usepackage{titling, graphicx}
\usepackage{tikz}
\usepackage{upgreek}
\usepackage{amsmath,amsthm}
\usepackage{strtikz}
\usetikzlibrary{shapes,arrows.meta,intersections,graphs,graphs.standard}
\usetikzlibrary{math,fit}
\usetikzlibrary{calc,intersections,through,backgrounds,decorations.pathmorphing}
\usetikzlibrary{patterns}
\documentclass[]{standalone}
\input{figs_opts.tex}
\begin{document}
\begin{tikzpicture}[line join=round]
\draw [line width=2pt] (0,0) -- (1.5,1.5) -- (1.5,0);
\draw [line width=2pt, line cap=round] (1.5,1.5) -- (3.0,1.5) -- (3.0,0);
\filldraw [fill=white, line width=1.25pt] (0, 0) circle[radius=1.5pt];
\filldraw [fill=white, line width=1.25pt] (1.5, 0) circle[radius=1.5pt];
\end{tikzpicture}
\end{document}
--
lyx-users mailing list
lyx-users@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-users