Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.11 KB | None | 0 0
  1. documentclass[10pt]{article}
  2. usepackage[margin=2cm]{geometry} % just for the example
  3. usepackage[frenchb]{babel}
  4. usepackage[table]{xcolor}
  5. usepackage{array}
  6. usepackage{tikz}
  7. usepackage{lipsum}
  8. usetikzlibrary{calc,shadings}
  9.  
  10. % Andrew Stacey's code from
  11. % http://tex.stackexchange.com/a/50054/3954
  12. makeatletter
  13. tikzset{%
  14. remember picture with id/.style={%
  15. remember picture,
  16. overlay,
  17. save picture id=#1,
  18. },
  19. save picture id/.code={%
  20. edefpgf@temp{#1}%
  21. immediatewritepgfutil@auxout{%
  22. noexpandsavepointas{pgf@temp}{pgfpictureid}}%
  23. },
  24. if picture id/.code args={#1#2#3}{%
  25. @ifundefined{save@pt@#1}{%
  26. pgfkeysalso{#3}%
  27. }{
  28. pgfkeysalso{#2}%
  29. }
  30. }
  31. }
  32.  
  33. defsavepointas#1#2{%
  34. expandaftergdefcsname save@pt@#1endcsname{#2}%
  35. }
  36.  
  37. deftmk@labeldef#1,#2@nil{%
  38. deftmk@label{#1}%
  39. deftmk@def{#2}%
  40. }
  41.  
  42. tikzdeclarecoordinatesystem{pic}{%
  43. pgfutil@in@,{#1}%
  44. ifpgfutil@in@%
  45. tmk@labeldef#1@nil
  46. else
  47. tmk@labeldef#1,(0pt,0pt)@nil
  48. fi
  49. @ifundefined{save@pt@tmk@label}{%
  50. tikz@scan@one@pointpgfutil@firstofonetmk@def
  51. }{%
  52. pgfsys@getposition{csname save@pt@tmk@labelendcsname}save@orig@pic%
  53. pgfsys@getposition{pgfpictureid}save@this@pic%
  54. pgf@process{pgfpointoriginsave@this@pic}%
  55. pgf@xa=pgf@x
  56. pgf@ya=pgf@y
  57. pgf@process{pgfpointoriginsave@orig@pic}%
  58. advancepgf@x by -pgf@xa
  59. advancepgf@y by -pgf@ya
  60. }%
  61. }
  62. newcommandtikzmark[2][]{%
  63. tikz[remember picture with id=#2] {#1;}}
  64. makeatother
  65. % end of Andrew's code
  66.  
  67. newcommandShadeCell[4][0pt]{%
  68. begin{tikzpicture}[overlay,remember picture]%
  69. shade[#4] ( $ (pic cs:#2) + (0pt,2ex) $ ) rectangle ( $ (pic cs:#3) + (0pt,-#1*baselineskip-.8ex) $ );
  70. end{tikzpicture}%
  71. }%
  72.  
  73. begin{document}
  74.  
  75. ShadeCell[14]{start1}{end1}{%
  76. shading=color wheel white center,opacity=.15}
  77. ShadeCell{start2}{end2}{%
  78. left color=red!20,right color=green!20}
  79. ShadeCell[13]{start3}{end3}{%
  80. top color=green!20,bottom color=red!20}
  81. ShadeCell{start4}{end4}{%
  82. left color=blue!20,right color=green!20}
  83.  
  84. begin{tabular}{| l | p{6cm} | c |}
  85. hline
  86. Uncolored cell
  87. & multicolumn{1}{!{tikzmark{start1}} p{6cm} !{vruletikzmark{end1}}}{lipsum*[2]}
  88. & Uncolored cell \
  89. hline
  90. multicolumn{1}{!{vruletikzmark{start2}} l !{vruletikzmark{end2}}}{Another colored cell}
  91. & Another uncolored cell & Another uncolored cell \
  92. hline
  93. Uncolored cell
  94. & lipsum[4]
  95. & multicolumn{1}{!{tikzmark{start3}} c !{vruletikzmark{end3}}}{Another colored cell} \
  96. hline
  97. multicolumn{2}{!{vruletikzmark{start4}} c !{vruletikzmark{end4}}}{Another merged colored cell}
  98. & Uncolored cell \
  99. hline
  100. end{tabular}
  101.  
  102. end{document}
  103.  
  104. !{tikzmark{<name1>}} <format> !{tikzmark{<name2>}}
  105.  
  106. !{vruletikzmark{<name1>}} <format> !{vruletikzmark{<name2>}}
  107.  
  108. ShadeCell{<name1>}{<name2>}{<shade specification>}
  109.  
  110. ShadeCell[4]{<name1>}{<name2>}{<shade specification>}
  111.  
  112. documentclass{article}
  113. usepackage{tikz}
  114. usetikzlibrary{matrix}
  115.  
  116. begin{document}
  117.  
  118. begin{tikzpicture}
  119.  
  120. matrix (A) [matrix of nodes,
  121. row 2 column 2/.style={ nodes = { top color=blue!20, bottom color=red!20 }}]
  122. {
  123. A & B & C \
  124. D & E & F \
  125. G & H & I \
  126. };
  127. end{tikzpicture}
  128.  
  129. end{document}
  130.  
  131. documentclass{article}
  132. usepackage{tikz}
  133. usetikzlibrary{matrix,calc}
  134.  
  135. begin{document}
  136.  
  137. begin{tikzpicture}
  138. matrix (A) [matrix of nodes, nodes in empty cells,
  139. text height=9pt, text depth = 1pt,
  140. row 3 column 1/.style={
  141. nodes = { top color=green!20, bottom color=red!20 }},
  142. row 2 column 2/.style={
  143. nodes = { left color=blue!20, right color=red!20 }},
  144. row 1 column 3/.style={
  145. nodes = { top color=blue!20, bottom color=red!20 }},
  146. column 1/.style={ text width=15mm, align=left },
  147. column 2/.style={ text width=15mm, align=right },
  148. column 3/.style={ minimum width=20mm} % centered!
  149. ]
  150. {
  151. Lorem & ipsum & dolor \
  152. sit & amet & consectetur \
  153. adipiscing& {} & {} \
  154. };
  155. % Draw some lines
  156. draw (A-1-1.north east) -- (A-3-1.south east);
  157. draw[thick, dotted] (A-2-2.south west) -- (A-2-3.south east) -- (A-1-3.north east);
  158. % Faked multicolumn
  159. node[text height=9pt,text depth=1pt] at ($(A-3-2)!0.50!(A-3-3)$) { Multicol text here };
  160. end{tikzpicture}
  161.  
  162. end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement