PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Frage zu eigenem Paket



MC3330
10-09-2018, 18:04
Hallo,

ich bin gerade damit beschäftigt die eigenes Paket zu erstellen für Sachen, die ich sehr häufig benutze.

Ich habe es jetzt hinbekommen, dass ich in meinem Paket ein neues Objekt per newcommand erstellen kann, dass dann gefunden wird, wenn ich das Paket einbinde.

Ich habe in mein Paket jetzt ein mit NewDocumentCommand erstelltes Objekt eingefügt. Das wird leider nicht gefunden, wenn ich das einbinde.

Kann man NewDocumentCommand nicht in einem Paket benutzen? Hat jemand eine Idee woran das sonst liegen kann?

Viele Grüße
Swizz



\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mein_paket}
\RequirePackage{tikz,pgfmath,xparse}

\newcommand{\xxx}{{ saa}}

\newcommand{\Simley}[1]{%
\begin{tikzpicture}[scale=0.5]
\newcommand*{\SmileyRadius}{1.0}%
\draw (0,0) circle (\SmileyRadius);% outside circle
\draw (-0.25cm,-1.2cm) -- (0.25cm,-1.2cm)--(0.25cm,-1.7cm)--(-0.25cm,-1.7cm)--cycle;
node [yshift=-0.22*\SmileyRadius cm] {\tiny #1}% uncomment this to see the smile factor
\end{tikzpicture}%
}%

\NewDocumentCommand{\zm3}{ O{} O{} O{} O{} O{} O{} O{1} }{
\fontsize{\the\numexpr10*#7}{\the\numexpr5*#7}
\begin{tikzpicture}[scale=#7]
\draw[line width =0.5*#7mm] (0,0) -- (6,0) -- (6,1) -- (0,1)--cycle;
\draw[line width =0.5*#7mm] (2,0)--(2,1);
\draw[line width =0.5*#7mm] (4,0)--(4,1);
\draw[line width =0.5*#7mm] (1,1) -- (5,1) -- (5,2) -- (1,2)--cycle;
\draw[line width =0.5*#7mm] (3,1)--(3,2);
\draw[line width =0.5*#7mm] (2,2) -- (4,2) -- (4,3) -- (2,3)--cycle;
\node at (1,0.5){#1};
\node at (3,0.5){#2};
\node at (5,0.5){#3};
\node at (2,1.5){#4};
\node at (4,1.5){#5};
\node at (3,2.5){#6};
\end{tikzpicture}%

}
\endinput

Johannes_B
11-09-2018, 05:56
Knapp zehn Jahre Mitglied im Forum und trotzdem kein Minimalbeispiel. :-/

Was wird denn nicht gefunden? Hast du mal unter dem Sofa nachgeschaut?

Mag LaTeX eventuell die drei (3) nicht?

https://tex.stackexchange.com/questions/3695/smileys-in-latex

MC3330
11-09-2018, 15:37
MR Unix


Knapp zehn Jahre Mitglied im Forum und trotzdem kein Minimalbeispiel. :-/

Sorry, du hast recht.

Die 3 ist in der Tat ein Problem, aber auch ohne klappt es nicht.

So sieht mein Paket aus:


\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mein_paket}
\RequirePackage{tikz,pgfmath,xparse}
\newcommand{\xxx}{{ saa}}
\newcommand{\Simley}[1]{%
\begin{tikzpicture}[scale=0.5]
\newcommand*{\SmileyRadius}{1.0}%
\draw (0,0) circle (\SmileyRadius);% outside circle
\draw (-0.25cm,-1.2cm) -- (0.25cm,-1.2cm)--(0.25cm,-1.7cm)--(-0.25cm,-1.7cm)--cycle;
node [yshift=-0.22*\SmileyRadius cm] {\tiny #1}% uncomment this to see the smile factor
\end{tikzpicture}%
}%


\NewDocumentCommand{\zm}{ O{} O{} O{} O{} O{} O{} O{1} }{
\fontsize{\the\numexpr10*#7}{\the\numexpr5*#7}
\begin{tikzpicture}[scale=#7]
\draw[line width =0.5*#7mm] (0,0) -- (6,0) -- (6,1) -- (0,1)--cycle;
\draw[line width =0.5*#7mm] (2,0)--(2,1);
\draw[line width =0.5*#7mm] (4,0)--(4,1);
\draw[line width =0.5*#7mm] (1,1) -- (5,1) -- (5,2) -- (1,2)--cycle;
\draw[line width =0.5*#7mm] (3,1)--(3,2);
\draw[line width =0.5*#7mm] (2,2) -- (4,2) -- (4,3) -- (2,3)--cycle;
\node at (1,0.5){#1};
\node at (3,0.5){#2};
\node at (5,0.5){#3};
\node at (2,1.5){#4};
\node at (4,1.5){#5};
\node at (3,2.5){#6};
\end{tikzpicture}%

}
\endinput



Dieses MB klappt problemlos


%präambel
\documentclass[fleqn,11pt,a4paper,liststotoc,bibtotoc,DIV15,BCOR1 2mm]{scrartcl}
\usepackage{mein_paket}
\begin{document}

\Simley[1]
\xxx
\end{document}


Bei diesem MB

%präambel
\documentclass[fleqn,11pt,a4paper,liststotoc,bibtotoc,DIV15,BCOR1 2mm]{scrartcl}
\usepackage{mein_paket}
\begin{document}

\zm
\end{document}



bekomme ich folgende Meldung:



Processing: mb.tex

Document Class: scrartcl 2018/03/30 v3.25 KOMA-Script document class (article)

Latex Error: ./mb.tex:6 Undefined control sequence.

Complete transcript is in mb.log

Command xelatex -interaction=nonstopmode -file-line-error-style -synctex=1 exited with status 1

Found 1 error, and 0 warnings in 1 run




Er scheint das Kommando \zm irgendwie nicht zu finden. Wenn ich das so definierte \zm in eine andere Datei kopiere, dann klappt es.

Johannes_B
12-09-2018, 06:19
\begin{filecontents}{\jobname.sty}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mein_paket}
\RequirePackage{tikz,pgfmath,xparse}
\newcommand{\xxx}{{ saa}}
\newcommand{\Simley}[1]{%
\begin{tikzpicture}[scale=0.5]
\newcommand*{\SmileyRadius}{1.0}%
\draw (0,0) circle (\SmileyRadius);% outside circle
\draw (-0.25cm,-1.2cm) -- (0.25cm,-1.2cm)--(0.25cm,-1.7cm)--(-0.25cm,-1.7cm)--cycle;
node [yshift=-0.22*\SmileyRadius cm] {\tiny #1}% uncomment this to see the smile factor
\end{tikzpicture}%
}%


\NewDocumentCommand{\zm}{ O{} O{} O{} O{} O{} O{} O{1} }{
\fontsize{\the\numexpr10*#7}{\the\numexpr5*#7}
\begin{tikzpicture}[scale=#7]
\draw[line width =0.5*#7mm] (0,0) -- (6,0) -- (6,1) -- (0,1)--cycle;
\draw[line width =0.5*#7mm] (2,0)--(2,1);
\draw[line width =0.5*#7mm] (4,0)--(4,1);
\draw[line width =0.5*#7mm] (1,1) -- (5,1) -- (5,2) -- (1,2)--cycle;
\draw[line width =0.5*#7mm] (3,1)--(3,2);
\draw[line width =0.5*#7mm] (2,2) -- (4,2) -- (4,3) -- (2,3)--cycle;
\node at (1,0.5){#1};
\node at (3,0.5){#2};
\node at (5,0.5){#3};
\node at (2,1.5){#4};
\node at (4,1.5){#5};
\node at (3,2.5){#6};
\end{tikzpicture}%

}
\endinput

\end{filecontents}
\documentclass[fleqn,11pt,a4paper,liststotoc,bibtotoc,DIV15,BCOR1 2mm]{scrartcl}
\usepackage{\jobname}
\begin{document}

\zm
\end{document}


Zugestanden, mein System ist nicht ganz up-to-date, ich erhalte keine Fehlermeldung. Dafür Warnungen, da einige deiner Klassenoptionen veraltet sind. Dein Editor sagt in der Zusammenfassung, dass es keine Warnungen gab.

Deine exakte Fehlermeldung hast du uns auch nicht präsentiert.

MC3330
18-10-2018, 19:37
Danke nochmal für die Hilfe. Ich habe den Fehler jetzt endlich gefunden, es lag nicht am Paket selbst. Ich hatte ich einen Fehler beim beim Pfad.