Open pgf-tikz-bot opened 6 years ago
@tallmarmot @Mo-Gul I have now more or less finished the extractor script. You can give it a go using the following bash script
#!/bin/bash
mkdir -p mwe
texlua extract.lua text-en/ mwe/
cd mwe
n=1
N=$(ls -1q *.tex | wc -l)
for i in *.tex; do
echo -n "Processing $n/$N $i"
if [ -f "${i%%.tex}.pdf" ]; then
echo -n " Skipped." # skip existing
else
lualatex -interaction=batchmode -halt-on-error "$i" > /dev/null
if [ "x$?" == "x1" ]; then
echo -n " Failed!"
fi
fi
echo ""
n=$((n+1))
done
Save this script as, say build.sh
in doc/generic/pgf/
next to extract.lua
. Then you can run it using bash build.sh
. Since this typesets all the examples individually, it takes a lot of time. The output will look like
[...snip...]
Processing 59/2128 pgfmanual-en-base-animations-8.tex
Processing 60/2128 pgfmanual-en-base-animations-9.tex
Processing 61/2128 pgfmanual-en-base-arrows-17.tex Failed!
Processing 62/2128 pgfmanual-en-base-arrows-8.tex Failed!
Processing 63/2128 pgfmanual-en-base-arrows-9.tex Failed!
Processing 64/2128 pgfmanual-en-base-decorations-11.tex
Processing 65/2128 pgfmanual-en-base-decorations-12.tex
Processing 66/2128 pgfmanual-en-base-decorations-1.tex
[...snip...]
As you can see not all of the examples typeset out-of-the-box. For the failed ones, you can inspect the log to find the error. As you can see from the extractor script
I currently just include all libraries in the preamble. This of course has to change. We only want to use the libraries which are necessary for each example.
@hmenke, thank you very much for providing the extractor script. I gave it a try and it works perfectly fine. And you are right, it takes a lot of time. Since I don't have clue about Bash scripts: Is there a chance to parallize the compilation?
@tallmarmot, what do you think about the extractor script? Do you see a chance to modify it according to "our understanding"?
Here is a script which runs in parallel on all available processors.
#!/bin/bash
mkdir -p mwe
texlua extract.lua text-en/ mwe/
cd mwe
ls -1q *.tex | sort | xargs -I @ -P `nproc` bash -c '
i="@"
str="Building $i"
if [ -f "${i%%.tex}.pdf" ]; then
str="$str Skipped."
else
lualatex -interaction=batchmode -halt-on-error "$i" > /dev/null
if [ "x$?" == "x1" ]; then
str="$str Failed!"
fi
fi
echo $str'
Works like a charm. Thank you for that. The only downside is that now one doesn't have a clue about the progress. But I think one has to live with this minor issue.
I could add a counter again but that would require some sort of locking mechanism because xargs
runs in parallel and I don't think bash variables are atomic.
@Mo-Gul I needed this for something else, so I had a look at how to lock file descriptors in Bash. Here is a new script with counter.
#!/bin/bash
mkdir -p mwe
texlua extract.lua text-en/ mwe/
cd mwe
touch /tmp/pgfmanuallock
echo 1 > /tmp/pgfmanualcount
ls -1q *.tex | sort | xargs -I @ -P `nproc` bash -c '
i="@"
{ flock -x 200;
n=$(cat /tmp/pgfmanualcount);
echo $((n+1)) > /tmp/pgfmanualcount;
} 200> /tmp/pgfmanuallock
str="Building $n/$(ls -1q *.tex | wc -l) $i"
if [ -f "${i%%.tex}.pdf" ]; then
str="$str Skipped."
else
lualatex -interaction=batchmode -halt-on-error "$i" > /dev/null
if [ "x$?" == "x1" ]; then
str="$str Failed!"
fi
fi
echo $str'
I have also run the script to see how many examples currently fail even in the presence of all libraries and there are luckily only few (181 out of 2128).
grep Failed build.log
That means for all the other examples you can go ahead and check which libraries are actually needed. Let's choose for example
pgfmanual-en-base-decorations-1.tex
For this we only need \usetikzlibrary{decorations,decorations.pathmorphing}
, so I go to the corresponding location in the manual and add the libraries to the options of the codeexample
.
https://github.com/pgf-tikz/pgf/blob/4c3ab05b40608c4b2f499b9aedae0fcf30c738fa/doc/generic/pgf/text-en/pgfmanual-en-base-decorations.tex#L27-L29
It will show up in the manual like this:
For now this is only a preliminary solution and the details might change in the future, but if you could add all the required libraries for each codeexample
that would be a great help. Right now, libraries/tikz
and libraries/pgf
are available, so it is best to start with those examples which do not require \usegdlibrary
or \usepackage
in the preamble.
@hmenke, great work (as always). It seems that the both keys libraries/tikz
and libraries/pgf
are not enough (for automated testing). We need another key that holds \tikzset
stuff and doesn't show up in the manual. This is needed e.g. for the tutorial examples. Have a look at e.g.
https://github.com/pgf-tikz/pgf/blob/4c3ab05b40608c4b2f499b9aedae0fcf30c738fa/doc/generic/pgf/text-en/pgfmanual-en-tutorial-chains.tex#L253-L266
(which corresponds to the extracted pgfmanual-en-tutorial-chains-4.tex
) where the terminal
style is no longer defined/repeated ...
The definitions of the styles are given at the beginning of the file https://github.com/pgf-tikz/pgf/blob/4c3ab05b40608c4b2f499b9aedae0fcf30c738fa/doc/generic/pgf/text-en/pgfmanual-en-tutorial-chains.tex#L25-L50 Maybe you have an idea how to add grab/store them and then either state the needed styles or just all of them. But in the latter case there is needed some kind of a reset thus that not all following examples contain stuff that is not needed any more.
To make it not too easy there is a need to grab several \tikzset
s. E.g. for the given example the definition of the styles is updated later in the file
https://github.com/pgf-tikz/pgf/blob/4c3ab05b40608c4b2f499b9aedae0fcf30c738fa/doc/generic/pgf/text-en/pgfmanual-en-tutorial-chains.tex#L336-L338
Also we need to grab definitions
https://github.com/pgf-tikz/pgf/blob/4c3ab05b40608c4b2f499b9aedae0fcf30c738fa/doc/generic/pgf/text-en/pgfmanual-en-tutorial-chains.tex#L542-L573
(which corresponds to the extracted pgfmanual-en-tutorial-chains-15.tex
).
If my above suggestion cannot be implemented (easily), maybe there is a possibility to abuse the codeexample
s pre
key (see previous code snippet) for our needs?
We also need something that allows us to load pgfmodules (e.g. for nonlinear transformations) unless we agree on changing the corresponding libraries in such a way that they always load the corresponding modules automatically. Whether or not we need the \tikzset
I do not have a strong opinion on because after all at the corresponding place in the manual this is explained very well. However, one conceivable way to go would be a key "other" which can be used to add everything else like \usepgfmodule
or \tikzset
such that all commands run through. (If I would know how I can check out the current version of the repository and commit changes, I would be able to test all the above. Is there a tutorial which is not entirely stupid and allows one to see how that works?)
@tallmarmot, you are right. Just having a look at the manual you don't need to "catch" the \tikzset
s. But for the automatic testing using the above bash script you need them ... (That I already tried to say in my previous comment, but maybe it wasn't clear enough.)
Ok, for now I use the pre
key and added all styles and definitions. This works fine. Only drawback is that styles and definitions containing hashes need to be provided in double form, e.g.
But of course then also in the extracted files the hashes are doubled, but need to be in single form. In all these cases I added comment lines on top, thus the user has an idea what he has to do to make the example work. Of course this doesn't help for the automatic testing. These lines start with % !!!
(and in the code of course with pre={ % !!!
).
Also I have found out that
isn't extracted. When I remove the optional argument it is. Is this a bug in extract.lua
?
width={4cm}
should help as a workaround.
Fixed in 0a6f19790dd3a99f8a9a59479416aa21954f7334
Following the request by @tallmarmot I have changed the way libraries are listed. I have removed the libraries/tikz
and libraries/pgf
options and replaced it with a single option preamble
in which you can put anything that should go in the preamble, e.g.
https://github.com/pgf-tikz/pgf/blob/36803f77cc11e6a04269e53d26c6f9f396a5cfac/doc/generic/pgf/text-en/pgfmanual-en-base-decorations.tex#L27-L29
Right now the content of preamble
is simply piped through \detokenize
. I might add more elaborate formatting in the future but I think this approach is flexible enough for now. Remember, the main objective currently is to identify which libraries are required to make each example compile. Pretty printing in the manual is only secondary at this point.
@hmenke, it would be nice if you could add some more features
setup code
.codeexample
that the collected setup code
can be ignored in this codeexample
.To 1: Background is that sometimes styles or definitions are only needed for a section and not for the whole chapter. Simply enclosing this codeexample
in (curly) braces like
{
\begin{codeexample}[setup code,hidden]
....
\end{codeexample}
...
}
will nonetheless add this collected stuff to a codeexample
after the closing (curly) brace.
To 2: Sometimes there are simple examples to introduce some stuff before this is applied to the "real" example. Of course for these all the collected stuff is not needed and might confuse users when they see all these definitions.
You have clearly not understood what this task is about. Let me make this clear:
The aim is to annotate the examples in the manual with the necessary \usetikzlibrary
etc. such that a user reading the manual can easily infer which libraries and packages to include in their document to obtain the demonstrated functionality.
The aim is not to make the examples copy-pastable or anything like that. Also the purpose of the extract.lua
is not to generate the most minimal example from the code in the manual, but to extract a compilable example that we can use for regression testing.
Understood. Step 1 is: Just annotate such that codeexample
s are compilable after extraction.
There is another source for the manual files used for the graphdrawing
library. They are found at https://github.com/pgf-tikz/pgf/tree/master/tex/generic/pgf/graphdrawing/lua/pgf/gd.
You decide if its best to adapt extract.lua
such that it grabs these examples, too or if you add another script in that location only for these examples.
Ok, I am through the codeexample
s found in https://github.com/pgf-tikz/pgf/tree/master/doc/generic/pgf/text-en. There are 171 remaining instances. Shall I first merge the branch I created to the master and then do a pull request or directly do a pull request?
Some comments to the remaining instances:
pgfmanual-en-dv-stylesheets.tex
where https://github.com/Mo-Gul/pgf/blob/f1b8890a941d5f89e36f7cd6ca98001faf4b998d/doc/generic/pgf/text-en/pgfmanual-en-dv-stylesheets.tex#L78-L99 is needed in (almost) all codeexample
s as pre
. So I guess you need to add another handler for that.pgfmanual-en-dv-axes.tex
where https://github.com/Mo-Gul/pgf/blob/da503508e88f3d377475ff2f62634da9429bd868/doc/generic/pgf/text-en/pgfmanual-en-dv-axes.tex#L2717-L2750 is needed in the remaining codeexample
s as pre
. --> see previous item.pgfmanual-en-pgfsys-animations.tex
remember picture
/overlay
And here some comments on the resulting pgfmanual.pdf
:
preamble
stuff is e.g. shown as \usetikzlibrary {...}
--> remove the space after the commandsetup code,hidden
isn't added/appended to the preamble
stuff and thus doesn't show up. Is this intended? I would say sometimes this is useful, sometimes not. --> Add another option/key--value?setup code
does the same thing in extract.lua
as putting it into the pre
key of every example. There are a lot more interdependencies though, e.g. this https://github.com/Mo-Gul/pgf/blob/f1b8890a941d5f89e36f7cd6ca98001faf4b998d/doc/generic/pgf/text-en/pgfmanual-en-dv-stylesheets.tex#L322-L329dvisvgm
. Please ignore these for now.extract.lua
to check for remember picture
(overlay
alone should work though).hidden
key should probably be removed and a sentence about the code should be added to the text.I've updated the extractor script to also work with the graphdrawing examples and to ignore remember picture
. Here is an updated build script:
#!/bin/bash
mkdir -p mwe
texlua extract.lua text-en/ ../../../tex/generic/pgf/graphdrawing/lua/pgf/ mwe/
cd mwe
touch /tmp/pgfmanuallock
echo 1 > /tmp/pgfmanualcount
ls -1q *.tex */**/*.tex | sort | xargs -I @ -P `nproc` bash -c '
d=`dirname "@"`;
f=`basename "@"`;
{ flock -x 200;
n=$(cat /tmp/pgfmanualcount);
echo $((n+1)) > /tmp/pgfmanualcount;
} 200> /tmp/pgfmanuallock
str="Building $n/$(ls -1q *.tex */**/*.tex | wc -l) $d/$f"
cd $d;
if [ -f "${f%%.tex}.pdf" ]; then
str="$str Skipped."
else
lualatex -interaction=batchmode -halt-on-error "$f" > /dev/null
if [ "x$?" == "x1" ]; then
str="$str Failed!"
fi
fi
echo $str'
Hi Henri,
Leider bekomme ich
mratz@MacBook-Pro-2:~/Documents/GitHub/pgf/doc/generic/pgf> ./build.sh
Usage: texlua extract.lua
./build.sh: line 8: nproc: command not found
xargs: max. processes must be >0
ls: */*/.tex: No such file or directory
Was mache ich falsch?
Ciao,
Michael
On Thu, Jul 4, 2019 at 12:43 AM Henri Menke notifications@github.com wrote:
I've updated the extractor script to also work with the graphdrawing examples and to ignore remember picture. Here is an updated build script:
!/bin/bash
mkdir -p mwe texlua extract.lua text-en/ ../../../tex/generic/pgf/graphdrawing/lua/pgf/ mwe/cd mwe
touch /tmp/pgfmanuallockecho 1 > /tmp/pgfmanualcount ls -1q .tex /*/.tex | sort | xargs -I @ -P
nproc
bash -c ' d=dirname "@"
; f=basename "@"
; { flock -x 200; n=$(cat /tmp/pgfmanualcount); echo $((n+1)) > /tmp/pgfmanualcount; } 200> /tmp/pgfmanuallock str="Building $n/$(ls -1q .tex /*/.tex | wc -l) $d/$f" cd $d; if [ -f "${f%%.tex}.pdf" ]; then str="$str Skipped." else lualatex -interaction=batchmode -halt-on-error "$f" > /dev/null if [ "x$?" == "x1" ]; then str="$str Failed!" fi fi echo $str'— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pgf-tikz/pgf/issues/640?email_source=notifications&email_token=AISROXABUTDMQCGCQTSZNKTP5UTQRA5CNFSM4HD7XP72YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZF3PYQ#issuecomment-508278754, or mute the thread https://github.com/notifications/unsubscribe-auth/AISROXHUTYNZXC5POIFKDXTP5UTQRANCNFSM4HD7XP7Q .
I see, macOS doesn't seem to have nproc
. You can replace it with sysctl -n hw.ncpu
.
@hmenke, and for your information. Under Win7 flock
isn't present. It also doesn't seem to be available in MinGW. Any ideas for a counter solution working under Windows?
That's why I am currently "just" running the solution with parallelization but without the counter (https://github.com/pgf-tikz/pgf/issues/640#issuecomment-487755301).
A "dummy" solution could be to clear help files (AUX, LOG), count all TEX files minus the number of PDF files to get the total number of files that need to be processed. Then counting the number of LOG files gives number of processed files ...
- No, that is not the only problem. BTW,
setup code
does the same thing inextract.lua
as putting it into thepre
key of every example. There are a lot more interdependencies though, e.g. this https://github.com/Mo-Gul/pgf/blob/f1b8890a941d5f89e36f7cd6ca98001faf4b998d/doc/generic/pgf/text-en/pgfmanual-en-dv-stylesheets.tex#L322-L329
Maybe I should have mentioned that I had modified extract.lua
thus that setup code
is written in the preamble. I also did some other adjustments to get my stated results (see https://github.com/Mo-Gul/pgf/blob/PimpCodeexamples/doc/generic/pgf/extract.lua).
For the record: I have written a PowerShell script myself to have parallel processing of the extracted codeexample
s and having a counter. It works with PowerShell v5.1 available here.
# -----------------------------------------------------------------------------
# adapted from <https://hkeylocalmachine.com/?p=612>
# (2do: have a look at
# <https://devblogs.microsoft.com/scripting/weekend-scripter-a-look-at-the-poshrsjob-module/>
# maybe the module can help to simplify this script)
# -----------------------------------------------------------------------------
$DestFolder = "mwe"
### create `$DestFolder` if it doesn't exist already
If (-Not (Test-Path -Path $DestFolder -PathType Container )) {
New-Item -Path "$PSScriptRoot\" -Name $DestFolder -ItemType Directory
}
### extract `codeexample`s from the manual files
texlua extract.lua text-en/ ../../../tex/generic/pgf/graphdrawing/lua/pgf/ $DestFolder/
### TeX all extracted files in parallel
$Folder = $PSScriptRoot + "\$DestFolder"
$TexFiles = Get-ChildItem $Folder -Recurse -Include *.tex `
| Where {-Not (Test-Path -Path "$($_.Directory)\$($_.BaseName).pdf" -Pathtype Leaf)}
# Create Runspace Pool with `$MaxRunspaces` threads
[int]$MaxRunspaces = [int]$env:NUMBER_OF_PROCESSORS
$Pool = [RunspaceFactory]::CreateRunspacePool(1, $MaxRunspaces)
$Pool.ApartmentState = "MTA"
$Pool.Open()
$Runspaces = @()
# The script you want run against each host
$ScriptBlock = {
# Take a TeX file as a parameter
Param ($File);
$DirectoryName = $File.DirectoryName
$FileName = $File.Name
lualatex -interaction=batchmode -halt-on-error --output-directory="$DirectoryName" "$FileName"
}
# Loop through the files
ForEach ($TexFile In $TexFiles) {
$Runspace = [powershell]::Create()
# Add script block to runspace (use $Null to avoid noise)
$Null = $Runspace.AddScript($ScriptBlock)
# Add the argument to the scriptblock (use $Null to avoid noise)
$Null = $Runspace.AddArgument($TexFile)
# Add/create new runspace
$Runspace.RunspacePool = $Pool
$Runspaces += [pscustomobject]@{Pipe=$Runspace; Status=$Runspace.BeginInvoke() }
}
# -------------------------------------------------------------------------
# Prepare the progress bar
$CurrentCount = 0;
$TotalCount = ($Runspaces | Measure-Object).Count;
# Pause until all runspaces have completed
While ($Runspaces.Status -ne $Null)
{
$Completed = $Runspaces | Where { $_.Status.IsCompleted -eq $True };
# Update progress bar
$CurrentCount = $CurrentCount + ($Completed | Measure-Object).Count;
$StatusText = "Completed $CurrentCount/$TotalCount"
Write-Progress `
-Activity "TeXing files..." `
-Status $StatusText `
-PercentComplete (([int]$CurrentCount/[int]$TotalCount)*100);
# Clear completed runspaces
ForEach ($Runspace In $Completed)
{
$Runspace.Pipe.EndInvoke($Runspace.Status)
$Runspace.Status = $Null
}
}
# -------------------------------------------------------------------------
# Clean-up Runspace Pool
$Pool.Close();
$Pool.Dispose();
# recursively delete empty folders
# (from <https://www.powershelladmin.com/wiki/PowerShell_script_to_recursively_delete_empty_folders>)
Get-ChildItem -LiteralPath $Folder -Force -Recurse `
| Where-Object {
$_.PSIsContainer -and `
@(Get-ChildItem -LiteralPath $_.Fullname -Force -Recurse `
| Where { -not $_.PSIsContainer }).Count -eq 0 `
} `
| Remove-Item -Recurse
@hmenke, it seems that there are even more (code)examples in the (Lua) documentation. Unfortunately they have another syntax. Here an example.
I guess you will easily be able to adapt extract.lua
again. But currently I don't have a clue how/where to add options to these (code) examples. Could you give me a hint for that?
@hmenke, I have worked through the codeexample
s and example
(s) in the Lua part of the documentation as well now. Regarding the example
s which need to have a preamble
option I have marked with % TODOsp: codeexamples:
and stated what is needed there.
I also searched myself for more example
s and didn't find any more (that are not commented), so I would say I am ready for a pull request. Shall I do a pull request for the branch or first merge it to the master and then do a pull request?
Sorry for stealing your time and disappointing you. After the events at texstackexchange last month my motivation to help the TeX community just dropped below zero. As long as Stefan Kottwitz is around there is no way I will be part of this. In any case, I cannot handle github so I was never of any use.
Best, M.
On Mon, Jul 15, 2019 at 9:25 AM Mo-Gul notifications@github.com wrote:
@hmenke https://github.com/hmenke, I have worked through the codeexamples and example(s) in the Lua part of the documentation as well now. Regarding the examples which need to have a preamble option I have marked with % TODOsp: codeexamples: and stated what is needed there.
I also searched myself for more examples and didn't find any more (that are not commented), so I would say I am ready for a pull request. Shall I do a pull request for the branch or first merge it to the master and then do a pull request?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pgf-tikz/pgf/issues/640?email_source=notifications&email_token=AISROXBSZNFTFAEVEM25RWDP7SQGZA5CNFSM4HD7XP72YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ6HCMQ#issuecomment-511471922, or mute the thread https://github.com/notifications/unsubscribe-auth/AISROXHX5IFRN6RLTVEOQ2DP7SQGZANCNFSM4HD7XP7Q .
@Mo-Gul I've put some stuff in place so that you can add options to the Lua examples.
A table of examples can be converted as such:
- examples = {[["
- \tikz \graph [spring electrical layout, horizontal=0 to 1]
- { 0 [electric charge=1] -- subgraph C_n [n=10] };
- "]],[["
- \tikz \graph [spring electrical layout, horizontal=0 to 1]
- { 0 [electric charge=5] -- subgraph C_n [n=10] };
- "]],[["
- \tikz \graph [spring electrical layout, horizontal=0 to 1]
- { [clique] 1 [electric charge=5], 2, 3, 4 };
- "]]
- }
+ examples = {
+ {
+ options = [["preamble={\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{force}}"]],
+ code = [["
+ \tikz \graph [spring electrical layout, horizontal=0 to 1]
+ { 0 [electric charge=1] -- subgraph C_n [n=10] };
+ "]]
+ },{
+ code = [["
+ \tikz \graph [spring electrical layout, horizontal=0 to 1]
+ { 0 [electric charge=5] -- subgraph C_n [n=10] };
+ "]]
+ },{
+ code = [["
+ \tikz \graph [spring electrical layout, horizontal=0 to 1]
+ { [clique] 1 [electric charge=5], 2, 3, 4 };
+ "]]
+ }
+ }
Sometimes though there are single examples, which are given as a string. These have to be wrapped in two tables (note the double braces in the example):
- examples = [["
- \tikz \graph [spring electrical layout, horizontal=0 to 1]
- { 0 [electric charge=1] -- subgraph C_n [n=10] };
- "]]
+ examples = {{
+ options = [["preamble={\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{force}}"]],
+ code = [["
+ \tikz \graph [spring electrical layout, horizontal=0 to 1]
+ { 0 [electric charge=1] -- subgraph C_n [n=10] };
+ "]]
+ }}
Please also disregard the code in tex/generic/pgf/graphdrawing/lua/pgf/gd/force/jedi
. This doesn't seem to be interfaced and doesn't even compile.
Thank you for the additions. I'll have a look at them. But it seems that I am not able to test them, because
[ ] currently the Lua examples (examples =
as you provided an example) are not extracted by the extract.lua
script.
[ ] Currently "only" the Lua examples given as codeexample
s are extracted and these also in a way that they can't be TeXed. For example
is extracted as
\documentclass{standalone}
\usepackage{fp,pgf,tikz,xcolor}
\usetikzlibrary{graphs,graphdrawing}
-- \usegdlibrary{force}
\begin{document}
-- \tikz \graph [spring layout, node distance=7mm] { subgraph C_n[n=3] };
-- \tikz \graph [spring layout] { subgraph C_n[n=3] };
-- \tikz \graph [spring layout, node distance=15mm]{ subgraph C_n[n=3] };
--
\end{document}
Could you fix this as well, i.e. remove the leading --
?
For the record: From the files in https://github.com/pgf-tikz/pgf/tree/master/doc/generic/pgf/text-en the extracted codeexample
s
don't compile.
@hmenke, applying the changes as you have stated in your comment above for multiple examples in one go show the options
stuff only at the first example (see the screenshot of another instance).
So either you see a possibility to state the options
once which then are applied to all the following code
s, e.g. as
examples = {
+ options = [["preamble={\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{force}}"]],
{
- options = [["preamble={\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{force}}"]],
code = [["
\tikz \graph [spring electrical layout, horizontal=0 to 1]
{ 0 [electric charge=1] -- subgraph C_n [n=10] };
"]]
},{
code = [["
\tikz \graph [spring electrical layout, horizontal=0 to 1]
{ 0 [electric charge=5] -- subgraph C_n [n=10] };
"]]
},{
code = [["
\tikz \graph [spring electrical layout, horizontal=0 to 1]
{ [clique] 1 [electric charge=5], 2, 3, 4 };
"]]
}
}
for your given code above or I add the options
to every code
instance of the examples, i.e.
examples = {
{
options = [["preamble={\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{force}}"]],
code = [["
\tikz \graph [spring electrical layout, horizontal=0 to 1]
{ 0 [electric charge=1] -- subgraph C_n [n=10] };
"]]
},{
+ options = [["preamble={\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{force}}"]],
code = [["
\tikz \graph [spring electrical layout, horizontal=0 to 1]
{ 0 [electric charge=5] -- subgraph C_n [n=10] };
"]]
},{
+ options = [["preamble={\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{force}}"]],
code = [["
\tikz \graph [spring electrical layout, horizontal=0 to 1]
{ [clique] 1 [electric charge=5], 2, 3, 4 };
"]]
}
}
How shall I proceed?
Hello.
The first example of phylogenetics with graphdrawing
on page 485 should also indicate the use of the 1st style \pgfgdset{..}
.
@Mo-Gul
So either you see a possibility to state the options once which then are applied to all the following codes ...
Currently such apply-all feature is not yet supported, but it doesn't seem difficult to achieve. Will post a small PR on this.
The generated pdf can be downloaded at https://github.com/hansonchar/pgf/actions/runs/9441252330
Migrated from SourceForge Author: krichter722 Timestamp: 2018-07-03 19:40:40.026000
I'm aware that the following is a huge pile of work, however I hope that you devs don't close it immediately because of that. It's intended to make this awesome software easier to use for beginners and trained users which tend to forget or can't keep up with the latest major changes:
It'd be nice to have a link to a Short, Self Contained, Correct (Compilable), Example for every code sample so that if you click on a link to a code sample like
on page xy you're redirected to the plain text file https://sourceforge.net/p/pgf/wiki/samples/001.tex which contains a SSCCE which can be directly passed to the compiler.
The manual describes what the user needs to do in a satisfying way, starting with
However, it's sometimes hard to follow all the packages which have been introduced and settings which have been changed over the course of the chapter where the snippet is shown (which can be dozens of pages long). The plain text links would avoid this and reduce the number of mistakes can make while using the snippet almost to zero.
This would also improve the incapacity of most PDF viewers to copy code accurate, i.e. without introducing unwanted linebreaks and replacing spaces with linebreaks, even though that's not PGF's job.
If you think that's a good idea regardless of the effort, then you might want to keep those SSCCEs coming piece by piece, maybe through merge requests. I can provide some, however, I often find myself trying to get the snippets to compile for hours which is the main reason why I'm suggesting this.
The SSCCEs could be provided for LaTeX, TeX, ConTeX and LuaLaTeX.