macros inside tikzpicture
I wanted to make a bit more readable the tex code I'm using and, in this respect, I wanted to somehow use a macro for the following code:
draw (10 mm,10 mm) -- (20 mm,10 mm);
I've created the following newcommands:
newcommand*horizontalLineCoor[3]{ draw (#1 mm,#2 mm) -- (#3 mm,#2 mm); }
newcommand*horizontalLineLength[3]{draw (#1 mm,#2 mm) -- (#1+#3 mm,#2 mm);}
I'm receiving this sort of errors:
! Package PGF Math Error: Unknown function `mm' (in '( mm').
See the PGF Math package documentation for explanation.
Type H <return> for immediate help.
...
l.31 horizontalLineLength(10
, 20, 10);
?
Can you give me hand with this macros:) Thank you!
R
The test file (this should draw 2 horizontal lines):
documentclass[a4paper,10pt,fleqn]{article}
usepackage{tikz}
usetikzlibrary{positioning}
newcommand*horizontalLineCoor[3]{ draw (#1 mm,#2 mm) -- (#3 mm,#2 mm); }
newcommand*horizontalLineLength[3]{draw (#1 mm,#2 mm) -- (#1+#3 mm,#2 mm);}
begin{document}
begin{figure}
begin{tikzpicture}[
xscale=2,
yscale=2,
virtual/.style={thin,dashed}
]
horizontalLineCoor(10, 10, 20); %%%draw (10 mm,10 mm) -- (20 mm,10 mm);
horizontalLineLength(10, 20, 10); %%%draw (10 mm,20 mm) -- (20 mm,20 mm);
end{tikzpicture}
caption{Interesting caption}
end{figure}
end{document}
tikz-pgf macros
New contributor
add a comment |
I wanted to make a bit more readable the tex code I'm using and, in this respect, I wanted to somehow use a macro for the following code:
draw (10 mm,10 mm) -- (20 mm,10 mm);
I've created the following newcommands:
newcommand*horizontalLineCoor[3]{ draw (#1 mm,#2 mm) -- (#3 mm,#2 mm); }
newcommand*horizontalLineLength[3]{draw (#1 mm,#2 mm) -- (#1+#3 mm,#2 mm);}
I'm receiving this sort of errors:
! Package PGF Math Error: Unknown function `mm' (in '( mm').
See the PGF Math package documentation for explanation.
Type H <return> for immediate help.
...
l.31 horizontalLineLength(10
, 20, 10);
?
Can you give me hand with this macros:) Thank you!
R
The test file (this should draw 2 horizontal lines):
documentclass[a4paper,10pt,fleqn]{article}
usepackage{tikz}
usetikzlibrary{positioning}
newcommand*horizontalLineCoor[3]{ draw (#1 mm,#2 mm) -- (#3 mm,#2 mm); }
newcommand*horizontalLineLength[3]{draw (#1 mm,#2 mm) -- (#1+#3 mm,#2 mm);}
begin{document}
begin{figure}
begin{tikzpicture}[
xscale=2,
yscale=2,
virtual/.style={thin,dashed}
]
horizontalLineCoor(10, 10, 20); %%%draw (10 mm,10 mm) -- (20 mm,10 mm);
horizontalLineLength(10, 20, 10); %%%draw (10 mm,20 mm) -- (20 mm,20 mm);
end{tikzpicture}
caption{Interesting caption}
end{figure}
end{document}
tikz-pgf macros
New contributor
add a comment |
I wanted to make a bit more readable the tex code I'm using and, in this respect, I wanted to somehow use a macro for the following code:
draw (10 mm,10 mm) -- (20 mm,10 mm);
I've created the following newcommands:
newcommand*horizontalLineCoor[3]{ draw (#1 mm,#2 mm) -- (#3 mm,#2 mm); }
newcommand*horizontalLineLength[3]{draw (#1 mm,#2 mm) -- (#1+#3 mm,#2 mm);}
I'm receiving this sort of errors:
! Package PGF Math Error: Unknown function `mm' (in '( mm').
See the PGF Math package documentation for explanation.
Type H <return> for immediate help.
...
l.31 horizontalLineLength(10
, 20, 10);
?
Can you give me hand with this macros:) Thank you!
R
The test file (this should draw 2 horizontal lines):
documentclass[a4paper,10pt,fleqn]{article}
usepackage{tikz}
usetikzlibrary{positioning}
newcommand*horizontalLineCoor[3]{ draw (#1 mm,#2 mm) -- (#3 mm,#2 mm); }
newcommand*horizontalLineLength[3]{draw (#1 mm,#2 mm) -- (#1+#3 mm,#2 mm);}
begin{document}
begin{figure}
begin{tikzpicture}[
xscale=2,
yscale=2,
virtual/.style={thin,dashed}
]
horizontalLineCoor(10, 10, 20); %%%draw (10 mm,10 mm) -- (20 mm,10 mm);
horizontalLineLength(10, 20, 10); %%%draw (10 mm,20 mm) -- (20 mm,20 mm);
end{tikzpicture}
caption{Interesting caption}
end{figure}
end{document}
tikz-pgf macros
New contributor
I wanted to make a bit more readable the tex code I'm using and, in this respect, I wanted to somehow use a macro for the following code:
draw (10 mm,10 mm) -- (20 mm,10 mm);
I've created the following newcommands:
newcommand*horizontalLineCoor[3]{ draw (#1 mm,#2 mm) -- (#3 mm,#2 mm); }
newcommand*horizontalLineLength[3]{draw (#1 mm,#2 mm) -- (#1+#3 mm,#2 mm);}
I'm receiving this sort of errors:
! Package PGF Math Error: Unknown function `mm' (in '( mm').
See the PGF Math package documentation for explanation.
Type H <return> for immediate help.
...
l.31 horizontalLineLength(10
, 20, 10);
?
Can you give me hand with this macros:) Thank you!
R
The test file (this should draw 2 horizontal lines):
documentclass[a4paper,10pt,fleqn]{article}
usepackage{tikz}
usetikzlibrary{positioning}
newcommand*horizontalLineCoor[3]{ draw (#1 mm,#2 mm) -- (#3 mm,#2 mm); }
newcommand*horizontalLineLength[3]{draw (#1 mm,#2 mm) -- (#1+#3 mm,#2 mm);}
begin{document}
begin{figure}
begin{tikzpicture}[
xscale=2,
yscale=2,
virtual/.style={thin,dashed}
]
horizontalLineCoor(10, 10, 20); %%%draw (10 mm,10 mm) -- (20 mm,10 mm);
horizontalLineLength(10, 20, 10); %%%draw (10 mm,20 mm) -- (20 mm,20 mm);
end{tikzpicture}
caption{Interesting caption}
end{figure}
end{document}
tikz-pgf macros
tikz-pgf macros
New contributor
New contributor
edited yesterday
radu
New contributor
asked yesterday
raduradu
362
362
New contributor
New contributor
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
You provided no test file but the error shows you used the syntax
horizontalLineLength(10, 20, 10);
But you have defined the command with three TeX arguments, that supplied the ;
so
horizontalLineLength{10}{20}{10}
add a comment |
You can use the syntax horizontalLineCoor(10, 10, 20)
if you prefer. However, this is a bit awkward, because TeX does not treat multiple arguments like C or other programming languages; if you define
newcommand{foo}[3]{...}
the call should be like
foo{x}{y}{z}
each argument enclosed in braces.
However, the syntax with parentheses can be set up using xparse
, that provides fairly general methods for inputting arguments.
documentclass[a4paper,10pt,fleqn]{article}
usepackage{xparse}
usepackage{tikz}
usetikzlibrary{positioning}
NewDocumentCommand{horizontalLineCoor}{>{SplitArgument{2}{,}}r()}{%
horizontalLineCoorDo#1%
}
NewDocumentCommand{horizontalLineLength}{>{SplitArgument{2}{,}}r()}{%
horizontalLineLengthDo#1%
}
NewDocumentCommand{horizontalLineCoorDo}{mmm}{%
horizontalLineDo{#1}{#2}{#3}%
}
NewDocumentCommand{horizontalLineLengthDo}{mmm}{%
horizontalLineDo{#1}{#2}{#1+#3}%
}
NewDocumentCommand{horizontalLineDo}{mmm}{%
draw (#1 mm,#2 mm) -- (#3 mm,#2 mm)%
}
begin{document}
begin{figure}[htp]
centering
begin{tikzpicture}[
xscale=2,
yscale=2,
virtual/.style={thin,dashed}
]
horizontalLineCoor(10, 10, 20); %%%draw (10 mm,10 mm) -- (20 mm,10 mm);
horizontalLineLength(10, 20, 10); %%%draw (10 mm,20 mm) -- (20 mm,20 mm);
end{tikzpicture}
caption{Interesting caption}
end{figure}
end{document}
The definition
NewDocumentCommand{horizontalLineCoor}{>{SplitArgument{2}{,}}r()}{%
horizontalLineCoorDo#1%
}
says that horizontalLineCoor
accepts one argument enclosed between parentheses; but we can tell LaTeX to split this argument at commas (there should be two of them), so at the end a call such as
horizontalLineCoor(10, 10, 20)
results in
horizontalLineCoorDo{10}{10}{20}
so the arguments are “TeX-normalized”. Now it's a matter of defining horizontalLineCoorDo
, which I do in an indirect fashion so as to avoid code duplication for the main code, since horizontalLineCoor
and horizontalLineLength
do very similar tasks.
add a comment |
This is just to remark that TikZ comes with its own means to define such abbreviations. Your commands can be represented by two styles, horizontal to
and horizontal add
, which do the same as what your commands should do (if I understand correctly).
documentclass[a4paper,10pt,fleqn]{article}
usepackage{tikz}
begin{document}
begin{figure}
begin{tikzpicture}[
xscale=2,
yscale=2,
horizontal to/.style={insert path={coordinate(aux) -- (#1mm,0 |-aux)}},
horizontal add/.style={insert path={-- ++ (#1mm,0)}},
]
draw (10mm,10mm) [horizontal to=20];
draw (10mm,20mm) [horizontal add=10];
end{tikzpicture}
caption{Interesting caption.}
end{figure}
end{document}
1
Eventually, the appropriate TikZ answer! (+1)
– CarLaTeX
21 hours ago
@CarLaTeX I can't guess what you mean, I got a badge for my answer!
– David Carlisle
17 hours ago
@DavidCarlisle lol
– CarLaTeX
17 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
radu is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f473074%2fmacros-inside-tikzpicture%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You provided no test file but the error shows you used the syntax
horizontalLineLength(10, 20, 10);
But you have defined the command with three TeX arguments, that supplied the ;
so
horizontalLineLength{10}{20}{10}
add a comment |
You provided no test file but the error shows you used the syntax
horizontalLineLength(10, 20, 10);
But you have defined the command with three TeX arguments, that supplied the ;
so
horizontalLineLength{10}{20}{10}
add a comment |
You provided no test file but the error shows you used the syntax
horizontalLineLength(10, 20, 10);
But you have defined the command with three TeX arguments, that supplied the ;
so
horizontalLineLength{10}{20}{10}
You provided no test file but the error shows you used the syntax
horizontalLineLength(10, 20, 10);
But you have defined the command with three TeX arguments, that supplied the ;
so
horizontalLineLength{10}{20}{10}
edited yesterday
answered yesterday
David CarlisleDavid Carlisle
488k4111271875
488k4111271875
add a comment |
add a comment |
You can use the syntax horizontalLineCoor(10, 10, 20)
if you prefer. However, this is a bit awkward, because TeX does not treat multiple arguments like C or other programming languages; if you define
newcommand{foo}[3]{...}
the call should be like
foo{x}{y}{z}
each argument enclosed in braces.
However, the syntax with parentheses can be set up using xparse
, that provides fairly general methods for inputting arguments.
documentclass[a4paper,10pt,fleqn]{article}
usepackage{xparse}
usepackage{tikz}
usetikzlibrary{positioning}
NewDocumentCommand{horizontalLineCoor}{>{SplitArgument{2}{,}}r()}{%
horizontalLineCoorDo#1%
}
NewDocumentCommand{horizontalLineLength}{>{SplitArgument{2}{,}}r()}{%
horizontalLineLengthDo#1%
}
NewDocumentCommand{horizontalLineCoorDo}{mmm}{%
horizontalLineDo{#1}{#2}{#3}%
}
NewDocumentCommand{horizontalLineLengthDo}{mmm}{%
horizontalLineDo{#1}{#2}{#1+#3}%
}
NewDocumentCommand{horizontalLineDo}{mmm}{%
draw (#1 mm,#2 mm) -- (#3 mm,#2 mm)%
}
begin{document}
begin{figure}[htp]
centering
begin{tikzpicture}[
xscale=2,
yscale=2,
virtual/.style={thin,dashed}
]
horizontalLineCoor(10, 10, 20); %%%draw (10 mm,10 mm) -- (20 mm,10 mm);
horizontalLineLength(10, 20, 10); %%%draw (10 mm,20 mm) -- (20 mm,20 mm);
end{tikzpicture}
caption{Interesting caption}
end{figure}
end{document}
The definition
NewDocumentCommand{horizontalLineCoor}{>{SplitArgument{2}{,}}r()}{%
horizontalLineCoorDo#1%
}
says that horizontalLineCoor
accepts one argument enclosed between parentheses; but we can tell LaTeX to split this argument at commas (there should be two of them), so at the end a call such as
horizontalLineCoor(10, 10, 20)
results in
horizontalLineCoorDo{10}{10}{20}
so the arguments are “TeX-normalized”. Now it's a matter of defining horizontalLineCoorDo
, which I do in an indirect fashion so as to avoid code duplication for the main code, since horizontalLineCoor
and horizontalLineLength
do very similar tasks.
add a comment |
You can use the syntax horizontalLineCoor(10, 10, 20)
if you prefer. However, this is a bit awkward, because TeX does not treat multiple arguments like C or other programming languages; if you define
newcommand{foo}[3]{...}
the call should be like
foo{x}{y}{z}
each argument enclosed in braces.
However, the syntax with parentheses can be set up using xparse
, that provides fairly general methods for inputting arguments.
documentclass[a4paper,10pt,fleqn]{article}
usepackage{xparse}
usepackage{tikz}
usetikzlibrary{positioning}
NewDocumentCommand{horizontalLineCoor}{>{SplitArgument{2}{,}}r()}{%
horizontalLineCoorDo#1%
}
NewDocumentCommand{horizontalLineLength}{>{SplitArgument{2}{,}}r()}{%
horizontalLineLengthDo#1%
}
NewDocumentCommand{horizontalLineCoorDo}{mmm}{%
horizontalLineDo{#1}{#2}{#3}%
}
NewDocumentCommand{horizontalLineLengthDo}{mmm}{%
horizontalLineDo{#1}{#2}{#1+#3}%
}
NewDocumentCommand{horizontalLineDo}{mmm}{%
draw (#1 mm,#2 mm) -- (#3 mm,#2 mm)%
}
begin{document}
begin{figure}[htp]
centering
begin{tikzpicture}[
xscale=2,
yscale=2,
virtual/.style={thin,dashed}
]
horizontalLineCoor(10, 10, 20); %%%draw (10 mm,10 mm) -- (20 mm,10 mm);
horizontalLineLength(10, 20, 10); %%%draw (10 mm,20 mm) -- (20 mm,20 mm);
end{tikzpicture}
caption{Interesting caption}
end{figure}
end{document}
The definition
NewDocumentCommand{horizontalLineCoor}{>{SplitArgument{2}{,}}r()}{%
horizontalLineCoorDo#1%
}
says that horizontalLineCoor
accepts one argument enclosed between parentheses; but we can tell LaTeX to split this argument at commas (there should be two of them), so at the end a call such as
horizontalLineCoor(10, 10, 20)
results in
horizontalLineCoorDo{10}{10}{20}
so the arguments are “TeX-normalized”. Now it's a matter of defining horizontalLineCoorDo
, which I do in an indirect fashion so as to avoid code duplication for the main code, since horizontalLineCoor
and horizontalLineLength
do very similar tasks.
add a comment |
You can use the syntax horizontalLineCoor(10, 10, 20)
if you prefer. However, this is a bit awkward, because TeX does not treat multiple arguments like C or other programming languages; if you define
newcommand{foo}[3]{...}
the call should be like
foo{x}{y}{z}
each argument enclosed in braces.
However, the syntax with parentheses can be set up using xparse
, that provides fairly general methods for inputting arguments.
documentclass[a4paper,10pt,fleqn]{article}
usepackage{xparse}
usepackage{tikz}
usetikzlibrary{positioning}
NewDocumentCommand{horizontalLineCoor}{>{SplitArgument{2}{,}}r()}{%
horizontalLineCoorDo#1%
}
NewDocumentCommand{horizontalLineLength}{>{SplitArgument{2}{,}}r()}{%
horizontalLineLengthDo#1%
}
NewDocumentCommand{horizontalLineCoorDo}{mmm}{%
horizontalLineDo{#1}{#2}{#3}%
}
NewDocumentCommand{horizontalLineLengthDo}{mmm}{%
horizontalLineDo{#1}{#2}{#1+#3}%
}
NewDocumentCommand{horizontalLineDo}{mmm}{%
draw (#1 mm,#2 mm) -- (#3 mm,#2 mm)%
}
begin{document}
begin{figure}[htp]
centering
begin{tikzpicture}[
xscale=2,
yscale=2,
virtual/.style={thin,dashed}
]
horizontalLineCoor(10, 10, 20); %%%draw (10 mm,10 mm) -- (20 mm,10 mm);
horizontalLineLength(10, 20, 10); %%%draw (10 mm,20 mm) -- (20 mm,20 mm);
end{tikzpicture}
caption{Interesting caption}
end{figure}
end{document}
The definition
NewDocumentCommand{horizontalLineCoor}{>{SplitArgument{2}{,}}r()}{%
horizontalLineCoorDo#1%
}
says that horizontalLineCoor
accepts one argument enclosed between parentheses; but we can tell LaTeX to split this argument at commas (there should be two of them), so at the end a call such as
horizontalLineCoor(10, 10, 20)
results in
horizontalLineCoorDo{10}{10}{20}
so the arguments are “TeX-normalized”. Now it's a matter of defining horizontalLineCoorDo
, which I do in an indirect fashion so as to avoid code duplication for the main code, since horizontalLineCoor
and horizontalLineLength
do very similar tasks.
You can use the syntax horizontalLineCoor(10, 10, 20)
if you prefer. However, this is a bit awkward, because TeX does not treat multiple arguments like C or other programming languages; if you define
newcommand{foo}[3]{...}
the call should be like
foo{x}{y}{z}
each argument enclosed in braces.
However, the syntax with parentheses can be set up using xparse
, that provides fairly general methods for inputting arguments.
documentclass[a4paper,10pt,fleqn]{article}
usepackage{xparse}
usepackage{tikz}
usetikzlibrary{positioning}
NewDocumentCommand{horizontalLineCoor}{>{SplitArgument{2}{,}}r()}{%
horizontalLineCoorDo#1%
}
NewDocumentCommand{horizontalLineLength}{>{SplitArgument{2}{,}}r()}{%
horizontalLineLengthDo#1%
}
NewDocumentCommand{horizontalLineCoorDo}{mmm}{%
horizontalLineDo{#1}{#2}{#3}%
}
NewDocumentCommand{horizontalLineLengthDo}{mmm}{%
horizontalLineDo{#1}{#2}{#1+#3}%
}
NewDocumentCommand{horizontalLineDo}{mmm}{%
draw (#1 mm,#2 mm) -- (#3 mm,#2 mm)%
}
begin{document}
begin{figure}[htp]
centering
begin{tikzpicture}[
xscale=2,
yscale=2,
virtual/.style={thin,dashed}
]
horizontalLineCoor(10, 10, 20); %%%draw (10 mm,10 mm) -- (20 mm,10 mm);
horizontalLineLength(10, 20, 10); %%%draw (10 mm,20 mm) -- (20 mm,20 mm);
end{tikzpicture}
caption{Interesting caption}
end{figure}
end{document}
The definition
NewDocumentCommand{horizontalLineCoor}{>{SplitArgument{2}{,}}r()}{%
horizontalLineCoorDo#1%
}
says that horizontalLineCoor
accepts one argument enclosed between parentheses; but we can tell LaTeX to split this argument at commas (there should be two of them), so at the end a call such as
horizontalLineCoor(10, 10, 20)
results in
horizontalLineCoorDo{10}{10}{20}
so the arguments are “TeX-normalized”. Now it's a matter of defining horizontalLineCoorDo
, which I do in an indirect fashion so as to avoid code duplication for the main code, since horizontalLineCoor
and horizontalLineLength
do very similar tasks.
answered yesterday
egregegreg
717k8719023194
717k8719023194
add a comment |
add a comment |
This is just to remark that TikZ comes with its own means to define such abbreviations. Your commands can be represented by two styles, horizontal to
and horizontal add
, which do the same as what your commands should do (if I understand correctly).
documentclass[a4paper,10pt,fleqn]{article}
usepackage{tikz}
begin{document}
begin{figure}
begin{tikzpicture}[
xscale=2,
yscale=2,
horizontal to/.style={insert path={coordinate(aux) -- (#1mm,0 |-aux)}},
horizontal add/.style={insert path={-- ++ (#1mm,0)}},
]
draw (10mm,10mm) [horizontal to=20];
draw (10mm,20mm) [horizontal add=10];
end{tikzpicture}
caption{Interesting caption.}
end{figure}
end{document}
1
Eventually, the appropriate TikZ answer! (+1)
– CarLaTeX
21 hours ago
@CarLaTeX I can't guess what you mean, I got a badge for my answer!
– David Carlisle
17 hours ago
@DavidCarlisle lol
– CarLaTeX
17 hours ago
add a comment |
This is just to remark that TikZ comes with its own means to define such abbreviations. Your commands can be represented by two styles, horizontal to
and horizontal add
, which do the same as what your commands should do (if I understand correctly).
documentclass[a4paper,10pt,fleqn]{article}
usepackage{tikz}
begin{document}
begin{figure}
begin{tikzpicture}[
xscale=2,
yscale=2,
horizontal to/.style={insert path={coordinate(aux) -- (#1mm,0 |-aux)}},
horizontal add/.style={insert path={-- ++ (#1mm,0)}},
]
draw (10mm,10mm) [horizontal to=20];
draw (10mm,20mm) [horizontal add=10];
end{tikzpicture}
caption{Interesting caption.}
end{figure}
end{document}
1
Eventually, the appropriate TikZ answer! (+1)
– CarLaTeX
21 hours ago
@CarLaTeX I can't guess what you mean, I got a badge for my answer!
– David Carlisle
17 hours ago
@DavidCarlisle lol
– CarLaTeX
17 hours ago
add a comment |
This is just to remark that TikZ comes with its own means to define such abbreviations. Your commands can be represented by two styles, horizontal to
and horizontal add
, which do the same as what your commands should do (if I understand correctly).
documentclass[a4paper,10pt,fleqn]{article}
usepackage{tikz}
begin{document}
begin{figure}
begin{tikzpicture}[
xscale=2,
yscale=2,
horizontal to/.style={insert path={coordinate(aux) -- (#1mm,0 |-aux)}},
horizontal add/.style={insert path={-- ++ (#1mm,0)}},
]
draw (10mm,10mm) [horizontal to=20];
draw (10mm,20mm) [horizontal add=10];
end{tikzpicture}
caption{Interesting caption.}
end{figure}
end{document}
This is just to remark that TikZ comes with its own means to define such abbreviations. Your commands can be represented by two styles, horizontal to
and horizontal add
, which do the same as what your commands should do (if I understand correctly).
documentclass[a4paper,10pt,fleqn]{article}
usepackage{tikz}
begin{document}
begin{figure}
begin{tikzpicture}[
xscale=2,
yscale=2,
horizontal to/.style={insert path={coordinate(aux) -- (#1mm,0 |-aux)}},
horizontal add/.style={insert path={-- ++ (#1mm,0)}},
]
draw (10mm,10mm) [horizontal to=20];
draw (10mm,20mm) [horizontal add=10];
end{tikzpicture}
caption{Interesting caption.}
end{figure}
end{document}
answered yesterday
marmotmarmot
97k4112213
97k4112213
1
Eventually, the appropriate TikZ answer! (+1)
– CarLaTeX
21 hours ago
@CarLaTeX I can't guess what you mean, I got a badge for my answer!
– David Carlisle
17 hours ago
@DavidCarlisle lol
– CarLaTeX
17 hours ago
add a comment |
1
Eventually, the appropriate TikZ answer! (+1)
– CarLaTeX
21 hours ago
@CarLaTeX I can't guess what you mean, I got a badge for my answer!
– David Carlisle
17 hours ago
@DavidCarlisle lol
– CarLaTeX
17 hours ago
1
1
Eventually, the appropriate TikZ answer! (+1)
– CarLaTeX
21 hours ago
Eventually, the appropriate TikZ answer! (+1)
– CarLaTeX
21 hours ago
@CarLaTeX I can't guess what you mean, I got a badge for my answer!
– David Carlisle
17 hours ago
@CarLaTeX I can't guess what you mean, I got a badge for my answer!
– David Carlisle
17 hours ago
@DavidCarlisle lol
– CarLaTeX
17 hours ago
@DavidCarlisle lol
– CarLaTeX
17 hours ago
add a comment |
radu is a new contributor. Be nice, and check out our Code of Conduct.
radu is a new contributor. Be nice, and check out our Code of Conduct.
radu is a new contributor. Be nice, and check out our Code of Conduct.
radu is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f473074%2fmacros-inside-tikzpicture%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown