Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. newcommand{tabler}[1]{matrix(m)[matrix of nodes, ampersand replacement=&]{#1};}
  2.  
  3. tabler{col 1&col 2&col 3&col 4}{3,1,3}
  4. |--col 1--|--col 2--|--col 3––|--col 4––|
  5. | width 3 | width 1 | width 3 |
  6.  
  7. documentclass{scrartcl}
  8.  
  9. usepackage{xparse, tikz}
  10. usetikzlibrary{matrix}
  11.  
  12. makeatletter
  13. newcommandtotcol{pgf@matrix@numberofcolumns}
  14. makeatother
  15.  
  16. pgfkeys{
  17. /tabler/execute macro/.style = {/tabler/save/.expand once=#1},
  18. /tabler/save/.store in=numcols
  19. }
  20.  
  21. NewDocumentCommandtabler{m}{
  22. matrix(m)[/tabler/execute macro={totcol},
  23. matrix of nodes,
  24. ampersand replacement=&] at (0,0)
  25. {#1};
  26. node at (0,0) {numcols{}};
  27. }
  28.  
  29. begin{document}
  30.  
  31. begin{tikzpicture}
  32. tabler{a & b& c & d & e\}
  33. end{tikzpicture}
  34.  
  35. end{document}
  36.  
  37. makeatletter
  38. newcommandtotcol{pgf@matrix@numberofcolumns}
  39. makeatother
  40.  
  41. documentclass[tikz,border=3.14mm]{standalone}
  42. usetikzlibrary{matrix}
  43. makeatletter
  44. tikzset{store number of columns in/.style={execute at end matrix={
  45. xdef#1{thepgf@matrix@numberofcolumns}}}}
  46. makeatother
  47. begin{document}
  48. begin{tikzpicture}
  49. matrix[matrix of nodes,store number of columns in=mymatcols] (mat){
  50. a & b & c & d & e\
  51. a & b & c & d & e\
  52. a & b & c & d & e\
  53. };
  54. draw[latex-latex] ([yshift=1ex]mat.north west) -- ([yshift=1ex]mat.north east)
  55. node[midway,fill=white]{mymatcols};
  56. end{tikzpicture}
  57. end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement