## 编译环境 操作系统 * [x] Windows 7/8/10 * [ ] macOS * [ ] Linux `若需勾选,请把[ ]改成[x]` Tex发行版 * [x] TexLive `年份` * [ ] MikTeX `版本号` * [ ] CTeX `若需勾选,请把[ ]改成[x]` ## 我的问题 ````markdown \documentclass[10pt]{article} \usepackage[paperwidth=21cm,paperheight=29.7cm,top=0.8cm,bottom=0.8cm,left=0.8cm,right=0.8cm]{geometry} \usepackage[UTF8]{ctex} \usepackage{pgfplots} \usepackage{color} \pagestyle{empty} \definecolor{lblue}{RGB}{51,153,255} \definecolor{dgray}{RGB}{224,224,224} \definecolor{lgreen}{RGB}{72,194,169} \begin{document} 我是一个东西 \begin{tikzpicture}[baseline] \draw (4.1cm, 0.4mm) node [anchor=mid west] {20\%}; \fill (0,0) [fill=dgray, rounded corners=0.1cm] rectangle ++(4cm, 0.2cm); \fill (0,0) [fill=lblue, rounded corners=0.1cm] rectangle ++(3cm, 0.2cm); \draw (4.1cm, -4mm) node [anchor=mid west] {50\%}; \fill (0,-0.5cm) [fill=dgray, rounded corners=0.1cm] rectangle ++(4cm, 0.2cm); \fill (0,-0.5cm) [fill=lgreen, rounded corners=0.1cm] rectangle ++(2cm, 0.2cm); \end{tikzpicture} \\ \end{document} ```` ![](https://wenda.latexstudio.net/data/attach/201104/h7GJL7nP.png) 左侧的文字怎么和右侧整体垂直居中对齐啊

2 回答2

0
可以用`minipage`整一下 ```tex \documentclass[10pt]{article} \usepackage[paperwidth=21cm,paperheight=29.7cm,top=0.8cm,bottom=0.8cm,left=0.8cm,right=0.8cm]{geometry} \usepackage[UTF8]{ctex} \usepackage{pgfplots} \usepackage{color} \pagestyle{empty} \definecolor{lblue}{RGB}{51,153,255} \definecolor{dgray}{RGB}{224,224,224} \definecolor{lgreen}{RGB}{72,194,169} \begin{document} \begin{minipage}{.14\linewidth} 我是一个东西 \end{minipage} \begin{minipage}{.4\linewidth} \begin{tikzpicture} \draw (4.1cm, 0.4mm) node [anchor=mid west] {20\%}; \fill (0,0) [fill=dgray, rounded corners=0.1cm] rectangle ++(4cm, 0.2cm); \fill (0,0) [fill=lblue, rounded corners=0.1cm] rectangle ++(3cm, 0.2cm); \draw (4.1cm, -4mm) node [anchor=mid west] {50\%}; \fill (0,-0.5cm) [fill=dgray, rounded corners=0.1cm] rectangle ++(4cm, 0.2cm); \fill (0,-0.5cm) [fill=lgreen, rounded corners=0.1cm] rectangle ++(2cm, 0.2cm); \end{tikzpicture} \end{minipage} \end{document} ``` 效果如下图 ![](https://wenda.latexstudio.net/data/attach/201104/77Wj9Hsm.png)
0
```c \definecolor{lblue}{RGB}{51,153,255} \definecolor{dgray}{RGB}{224,224,224} \definecolor{lgreen}{RGB}{72,194,169} 我是一个东西 \begin{tikzpicture}[baseline={($(current bounding box.center)+(0,-0.5em)$)}] \def\linelength{4} \draw [dgray,line width=2mm,line cap=round](0,0)--+(\linelength,0) node [black,right] {20\%}; \draw [lblue,line width=2mm,line cap=round](0,0)--+(0.8*\linelength,0); \draw [dgray,line width=2mm,line cap=round](0,-0.5)--+(\linelength,0) node [black,right] {50\%}; \draw [lblue,line width=2mm,line cap=round](0,-0.5)--+(0.5*\linelength,0); \end{tikzpicture} ```

你的回答

请登录后回答

你的回答将会帮助更多人,请务必认真回答问题。