« first day (226 days earlier)      last day (1577 days later) » 

2:32 PM
@marmot [Another question, still probably trivial] How to implement a command \pushback that works like this?
Initially, \myarray is {}
\pushback{1} -> \myarray is {1}
\pushback{-1} -> \myarray is {1,-1}
\pushback{100} -> \myarray is {1,-1,100}
Is there any PGF tools for that or do I have to use TeX commands?
 
\long\def\pushback#1%
  {%
    \edef\myarray
      {%
        \ifx\myarray\empty
          {\unexpanded{#1}}%
        \else
          {%
            \unexpanded\expandafter\expandafter\expandafter
              {%
                \expandafter\@firstofone\myarray,#1%
              }%
          }%
        \fi
      }%
  }
@JouleV ^^^^
 
@Skillmon So I will have to use TeX commands then... I am very reluctant to do so ;)
 
@JouleV I have no idea whether there exists anything in PGF/TikZ. But it is pretty simple in TeX :)
@JouleV oh, this will fail if you initialize \myarray as {} like this \def\myarray{{}} (I thought you meant \def\myarray{} as initial setup), wait a second.
@JouleV the following fixes that, by using a test set named \myemptyset instead of \empty:
\def\myemptyset{{}}
\long\def\pushback#1%
  {%
    \edef\myarray
      {%
        \ifx\myarray\myemptyset
          {\unexpanded{#1}}%
        \else
          {%
            \unexpanded\expandafter\expandafter\expandafter
              {%
                \expandafter\@firstofone\myarray,#1%
              }%
          }%
        \fi
      }%
  }
\def\myarray{{}}
\pushback{1}
\pushback{-1}
\show\myarray
keep in mind that \@firstofone is defined in LaTeX, in pgf you should use \pgfutil@firstofone instead to keep your code generic.
 
@Skillmon [You can pretend that I know absolutely nothing about TeX] The following code doesn't run
\documentclass{article}
\def\myemptyset{{}}
\long\def\pushback#1%
  {%
    \edef\myarray
      {%
        \ifx\myarray\myemptyset
          {\unexpanded{#1}}%
        \else
          {%
            \unexpanded\expandafter\expandafter\expandafter
              {%
                \expandafter\@firstofone\myarray,#1%
              }%
          }%
        \fi
      }%
  }
\def\myarray{{}}
\begin{document}
\pushback{2}
\pushback{4}
\pushback{1}
\pushback{-2}
\myarray
\end{document}
What should I do?
Again, please pretend that I know absolutely nothing about TeX :))
 
@JouleV for \@firstofone to work, you have to put a \makeatletter before \def\pushback and a \makeatother at the end (@ by default can't be part of a macro name and you have to tell TeX that it can by making @ a letter)
 
2:46 PM
@Skillmon Ah, forgot that. Wasn't really reading the code (how silly I was). Thanks :)
@Skillmon Now it is working perfectly, thank you very much!
 
@JouleV hm, not idea about pgf but with expl3 I would use \seq_push:Nn.
 
@UlrikeFischer I think he wants to use that as a pgf list with that strange syntax \myarray[0] of TikZ/pgf.
 
@Skillmon Precisely :) It looks more like an 'array' to me.
 
@JouleV list, array, those are just terms and can be used pretty interchangeably, some programming languages name them this, some that. But if you're happy, "array" :)
 
@Skillmon It is just a matter of familiarity, you know
 
2:55 PM
@Skillmon well if this is (as it looks like) a comma list, one can use \clist_put_right:Nn.
 
@UlrikeFischer the { and } are part of the macro definition (so it should be equivalent to \def\myarray{{1,2,3}}), \clist_put_right:Nn doesn't assume braces around the clist, iirc.
 
 
1 hour later…
user11685757
4:15 PM
@JouleV It depends on what you want to do. If these are just integers or strings, you could do
\documentclass{article}
\usepackage{pgf}
\begin{document}
\newcommand\pushback[1]{\ifcsname myarray\endcsname
\edef\myarray{\myarray,#1}
\else
\edef\myarray{#1}
\fi}
\pushback{1}\myarray

\pushback{-1}\myarray

\pushback{100}\myarray

\pgfmathsetmacro{\myitem}{{\myarray}[1]}\myitem


\renewcommand\pushback[1]{\ifcsname mystringarray\endcsname
\edef\mystringarray{\mystringarray,"#1"}
\else
\edef\mystringarray{"#1"}
 
user11685757
@JouleV There are many alternatives. If you want just to be able to get the i-th entry, and want something that does not slow down for large arrays, use maybe
\documentclass{article}
\newcounter{arrayindex}
\newcommand\pushback[1]{\stepcounter{arrayindex}%
\expandafter\def\csname myarray\number\value{arrayindex}\endcsname{#1}}
\newcommand\arrayentry[1]{\csname myarray#1\endcsname}
\begin{document}
\pushback{1}

\pushback{-1}

\pushback{100}

\pushback{\begin{itemize}}

\pushback{\end{itemize}}
 
4:33 PM
Yesterday while preparing a manuscript, I noticed that while loading TikZ externalised images that were generated by lualatex are incompatible with pdflatex compilation. What I mean by imcompatible is that few information from the images were lost, say, texts. I remember from @UlrikeFischer's message that pdf is also a form of script. So is it possible that these anomalies are root-cause from how pdflatex generates pdf and lualatex generates pdf.
PS: A particular publisher does not like direct TikZ graphics, so I had to externalise the graphics to create a pdf for the publisher's usage.
 
@Raaja fonts can be a problem if they are not embedded - or if they have the same name. But normally this works, and without a minimal example one can't say what went wrong in your case.
 
@UlrikeFischer Yes fonts were only the problem as far as I saw yesterday. For me it was counter intiutive because, only the engines were different whereas the class/styles were the same. Even with the same conditions can this happen? (the externalisation was performed with elsarticle class (in lualatex) and pdf was incorporated with wiley-AMA class (in pdflatex). Whereas this problem was not there when the engine was the same.
@UlrikeFischer May be I shall prepare a MWE tomorrow and let you know, thanks.
 
user11685757
5:13 PM
@Raaja For publications I often create small standalones for the pictures and submit the pdf, or choose a publisher who allows me to use TikZ. I never became friends with externalize. Once you start also playing with tikzmark the hell breaks loose. Most likely I am doing something wrong, but still in my experience it is so fragile that the time it promises to save you gets overcompensated by the time you need to tame it.
 
@marmot Thanks!
 
user11685757
@JouleV You're welcome! Needless to say that there are tons of packages. Apart form expl3 there is listofitems and so on. According to my own experience, for large arrays the last method is much faster than any method that loops through the list to extract item 217, say. Of course, expl3 enthusiasts will say that this method is not immune against user errors, which is true, but I personally sometimes like to have things that I fully understand and which do not depend on others.
 
7:30 PM
@marmot sometimes one has to do a lot for collaborations ;) I haven't tried with tikzmark yet. So far it's going good, especially the time for compiling the docs.
@marmot Nevertheless, in my experience, setting up extermalise wasnt that hard
 
user11685757
@Raaja Yes, as long as you do not do something tricky with remember picture. I am not saying it is impossible to make this work, too, but I found for myself that externalizing by hand can be easier, in particular in collaborations. Then others only have to include the pdf (of course I also add the standalone file to the project).
 
8:33 PM
@marmot by hand is always easier. And, I haven't tried with remember pictures as well ;)
 

« first day (226 days earlier)      last day (1577 days later) »