latex is fucking good. 当使用latex写文档后,发现它真的是太强大了,包含的内容如此之多,如此之广,可谓All in one, one is enough! 当然在使用它的时候会有很多很多细节无法记住,那么现将遇到的细小问题汇总于此,说明如下:

  • 主要用于汇总latex使用过程中遇到的各种小问题,方便以后查阅;
  • 涉及标签,命令等相关用法;
所有小问题如下: 1. Tikz绘图时,使node labels的位置位于node之下,而非node之中。 参考:Tikz node labels more below than below 解决方法: 在node的选项中加入label即可:
\begin{tikzpicture}
    \fill (0,0) circle (0.05) node[below,draw]{$b_1$};
    \fill (1,0) circle (0.05) node[label=below:$b_1$,draw]{};
\end{tikzpicture}

2.-tikz中,node里面的内容或label换行设置问题。 参考: How to add newline within node using TikZ? 解决方法:在node选项中加入align=center, 然后在使用换行符 \即可。
\documentclass[]{minimal}

\usepackage{amsmath,amsfonts,amssymb}
\usepackage{tikz}
\usetikzlibrary{automata,positioning}

\begin{document}

\begin{tikzpicture}[shorten >=1pt,node distance=5cm,on grid,auto] 

% 具体设置在这里
\node[state,initial] (q_0) {$q_0$}; 
\path[->] (q_0) edge[loop above] node[text width=1cm,align=center] {0,1,2\\3,4,5} (q_0); 

\end{tikzpicture}
\end{document}  

3.在tikz中,多个node如何设置一样的大小? 参考:how to draw nodes with same size 解决方法:在scope中设置minimum size和inner seq即可。
\documentclass[11pt,tikz,border=2pt]{standalone}
    \usetikzlibrary{positioning}
    \begin{document}
     \begin{tikzpicture}[scale=1.5]
      \begin{scope}[auto, every node/.style={draw,circle,minimum size=2em,inner sep=1},node distance=2cm]
        % the vertices
        \node(v1) at (0,0){1};
        \node[above=of v1] (v2) {2};
        \node[above=of v2] (v3) {3};
        \node[right=of v1] (v4) {4};
        \node[above=of v4] (v5) {5};
        \node[above=of v5] (v6) {6};
        \node[right=of v4] (v7) {7};
        \node[above=of v7] (v8) {8};
        \node[above=of v8] (v9) {9};
        \node[right=of v7 ,] (v10) {10};
        \node[above=of v10] (v11) {11};
        \node[above=of v11,] (v12) {12};
      \end{scope}
     \end{tikzpicture}
    \end{document}

4.tikz中,node相互之间的位置和距离如何设置? 参考:How to increase the horizontal distance between nodes? 解决方法:在node中加入这个[below right=0.7cm and 4cm of A]选项或xshift即可。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
  [align=center,node distance=2cm]  %< no need of this global node separation
  \node[label=above:A] (A)                      
       {(1)};
  \node[label=above:B1] (B1) [above right=0.7cm and 4cm of A]
       {($m+1$)};
  \node[label=above:B2] (B2) [below right=0.7cm and 4cm of A]
       {($m+1$)};
  \node[label=above:C] (C)  [below right=0.7cm and 4cm of B1]
       {($2m-1$)};
\end{tikzpicture}
\end{document}
或者使用下面的xshift参数:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}[state/.style={draw=red,ultra thick,rectangle,rounded corners}]

 \node[state] (q3)  {$test$}; 
 \node[state] (q4) [below left of=q3] {$homing$}; 
 \node[state] (q5) [below left of=q3,xshift=-2cm] {$homing1$}; 

\end{tikzpicture}

\end{document}

5.在tikz绘图中,使用for循环按照步长生成多个图的方法? 参考:Repeating Things: The Foreach Statement 解决方法:参考下面的例子。
% 下面12之间的间距即是步长,\y的用法一样。
\foreach \x in {1,2,...,6} {\x, } yields 1, 2, 3, 4, 5, 6,
\foreach \x in {1,2,3,...,6} {\x, } yields 1, 2, 3, 4, 5, 6,
\foreach \x in {1,3,...,11} {\x, } yields 1, 3, 5, 7, 9, 11,
\foreach \x in {1,3,...,10} {\x, } yields 1, 3, 5, 7, 9,
\foreach \x in {0,0.1,...,0.5} {\x, } yields 0, 0.1, 0.20001, 0.30002, 0.40002,
\foreach \x in {a,b,9,8,...,1,2,2.125,...,2.5} {\x, } yields a, b, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 2.125, 2.25, 2.375, 2.5,
\foreach \x in {1,...,6} {\x, } yields 1, 2, 3, 4, 5, 6,
\foreach \x in {9,...,3.5} {\x, } yields 9, 8, 7, 6, 5, 4,
% 使用方法如下
\tikz 
  \foreach \x in {0,1,...,3} 
    \draw (\x,0) circle (0.2cm);
error 选自:http://blog.csdn.net/fandroid/article/details/46930019

点赞(0)

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部