welche Pakete muss ich verwenden, damit LyX mit mathcha.io erstellte Bilder kompilieren und rendern kann?

welche Pakete muss ich verwenden, damit LyX mit mathcha.io erstellte Bilder kompilieren und rendern kann?

Ich verwende LyX und habe kürzlich herausgefunden, dass Sie mit mathcha.io Bilder und Diagramme, die Sie ganz einfach erstellen können, in Tikz-Code konvertieren können.

Ich habe versucht, es zu verwenden, aber beim Kompilieren zeigt es nur bestimmte Dinge an. Beispielsweise rendert es einige Logikgatterschaltungen, lädt aber keine Diagramme (2D, 3D usw.). (Ich füge hinzu, dass Sie, um in mathcha.io dorthin zu gelangen, zuerst die Diagramm-/Zeichenumgebung aufrufen müssen, indem Sie „\drawing“ eingeben.) Ich glaube also, dass mir einige Pakete fehlen. Hier ist ein Beispiel des von mathcha.io generierten Codes, der in einer TeX-Codeumgebung in LyX funktionieren soll, aber nicht rendert:

\tikzset{every picture/.style={line width=0.75pt}} %set default line width to 0.75pt        
\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] %uncomment if require: 
\path (0,300); %set diagram left start at 0, and has height of 300
\end{tikzpicture} 

und hier ist ein Beispiel für Code, der richtig gerendert wird (obwohl ich keine einfache Möglichkeit kenne, ihn an der exakten Stelle zu positionieren wie im LyX-Dokument):

\tikzset{every picture/.style={line width=0.75pt}} %set default line width to 0.75pt        
\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] %uncomment if require: \path (0,300); %set diagram left start at 0, and has height of 300
%Shape: Axis 2D [id:dp7108345265772975]  
\draw  (50,162) -- (150,162)(60,72) -- (60,172) (143,157) -- (150,162) -- (143,167) (55,79) -- (60,72) -- (65,79)  ; 
%Shape: Parabola [id:dp7278250032221381]  
\draw   (25,122) .. controls (48.33,175.33) and (71.67,175.33) .. (95,122) ; 
%Shape: Wave [id:dp767344400003916]  
\draw   (164.99,135.62) .. controls (161.1,125.31) and (157.38,115.48) .. (152.85,115.4) .. controls (148.33,115.32) and (144.26,125.01) .. (140,135.18) .. controls (135.74,145.35) and (131.67,155.03) .. (127.14,154.95) .. controls (122.62,154.87) and (118.9,145.05) .. (115,134.73) .. controls (111.11,124.42) and (107.38,114.59) .. (102.86,114.51) .. controls (100.2,114.47) and (97.69,117.8) .. (95.21,122.62) ;
\end{tikzpicture} 

Ich gehe davon aus, dass die Diagramme in mathcha.io auf eine Weise generiert werden, auf die nur über die Website selbst zugegriffen werden kann. Wenn Sie also versuchen, den Tikz-Code zu kopieren, gehen die Informationen darüber, was darin enthalten sein sollte, verloren.

Antwort1

\usepackage{tikz}Die eine oder andere Aussage muss in der Präambel stehen .

Schauen wir uns zunächst den LaTeX-Code an. Ich kopiere Ihre beiden Codes wie folgt:

\documentclass[10pt,border=3mm,tikz]{standalone}

\begin{document}

\tikzset{every picture/.style={line width=0.75pt}} %set default line width to 0.75pt        
\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] %uncomment if require: 
\path (0,300); %set diagram left start at 0, and has height of 300
\end{tikzpicture} 

\tikzset{every picture/.style={line width=0.75pt}} %set default line width to 0.75pt        
\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] %uncomment if require: \path (0,300); %set diagram left start at 0, and has height of 300
%Shape: Axis 2D [id:dp7108345265772975]  
\draw  (50,162) -- (150,162)(60,72) -- (60,172) (143,157) -- (150,162) -- (143,167) (55,79) -- (60,72) -- (65,79)  ; 
%Shape: Parabola [id:dp7278250032221381]  
\draw   (25,122) .. controls (48.33,175.33) and (71.67,175.33) .. (95,122) ; 
%Shape: Wave [id:dp767344400003916]  
\draw   (164.99,135.62) .. controls (161.1,125.31) and (157.38,115.48) .. (152.85,115.4) .. controls (148.33,115.32) and (144.26,125.01) .. (140,135.18) .. controls (135.74,145.35) and (131.67,155.03) .. (127.14,154.95) .. controls (122.62,154.87) and (118.9,145.05) .. (115,134.73) .. controls (111.11,124.42) and (107.38,114.59) .. (102.86,114.51) .. controls (100.2,114.47) and (97.69,117.8) .. (95.21,122.62) ;
\end{tikzpicture} 

\end{document}

es ergibt:

  • die standaloneKlasse legt eine "Seite" protikzpicture
  • Der erste enthält im Wesentlichen ... einen Punkt\path (0,300);
  • während die zweite sieht gut genug

Ergebnis

LyX scheint dagegen bei diesem Code etwas störrischer zu sein:

  • Documents / Settings / Preamble: \usepackage{tikz}dort hinzufügen
  • Beim Kopieren des zweiten Codes in die rote Box wurde die Vorschau nicht korrekt dargestellt
  • Es stellte sich heraus, dass ich Zeilenumbrüche eingeben musste, um die \drawAnweisungen manuell von ihrem Auskommentieren zu „befreien“ (??? LyX ...)

Leider kann ich es nicht kompilieren, aber hier als Referenz:

Bildbeschreibung hier eingeben

Lyx-Datei: in einen ASCII-Editor kopieren, speichern, laden, sollte an Ihrer Stelle kompiliert werden:

#LyX 2.3 created this file. For more info see http://www.lyx.org/
\lyxformat 544
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass article
\begin_preamble
\usepackage{tikz}
\end_preamble
\use_default_options true
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\use_microtype false
\use_dash_ligatures true
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 1
\use_minted 0
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\is_math_indent 0
\math_numbering_side default
\quotes_style english
\dynamic_quotes 0
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
tikzset{every picture/.style={line width=0.75pt}} %set default line width
 to 0.75pt         
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] %uncomment if require:
 
\backslash
path (0,300); %set diagram left start at 0, and has height of 300 %Shape:
 Axis 2D [id:dp7108345265772975]   
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout


\backslash
draw  (50,162) -- (150,162)(60,72) -- (60,172) (143,157) -- (150,162) --
 (143,167) (55,79) -- (60,72) -- (65,79)  ;  %Shape: Parabola [id:dp727825003222
1381]   
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout


\backslash
draw   (25,122) ..
 controls (48.33,175.33) and (71.67,175.33) ..
 (95,122) ;  %Shape: Wave [id:dp767344400003916]   
\backslash
draw   (164.99,135.62) ..
 controls (161.1,125.31) and (157.38,115.48) ..
 (152.85,115.4) ..
 controls (148.33,115.32) and (144.26,125.01) ..
 (140,135.18) ..
 controls (135.74,145.35) and (131.67,155.03) ..
 (127.14,154.95) ..
 controls (122.62,154.87) and (118.9,145.05) ..
 (115,134.73) ..
 controls (111.11,124.42) and (107.38,114.59) ..
 (102.86,114.51) ..
 controls (100.2,114.47) and (97.69,117.8) ..
 (95.21,122.62) ; 
\end_layout

\begin_layout Plain Layout


\backslash
end{tikzpicture} 
\end_layout

\end_inset


\end_layout

\end_body
\end_document

verwandte Informationen