我该如何做才能让 I. 和 II. 在框的中间水平对齐!?此外,我希望文本(灰色框)以粗体显示,但 \textbf 不起作用!?
谢谢你!
\documentclass[a4paper]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage[T1]{fontenc}
\usepackage[english,german,ngerman]{babel}
\usepackage{lmodern}
\usepackage{scrlayer-scrpage}
\usepackage{microtype}
\usepackage{ragged2e}
\usepackage{etoolbox}
\usepackage{booktabs}
\newcommand{\tabitem}{~~\llap{\textbullet}~~}
\newcommand\mc[1]{\multicolumn{2}{p{\dimexpr0.85\linewidth-3\tabcolsep\relax}}{#1}}
\usepackage{array}
%\usepackage[figuresright]{rotating}
\usepackage{enumitem}
\usepackage{fp}
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{positioning,shadings}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{decorations.shapes}
\usetikzlibrary{decorations.text}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{calc}
\usepackage[babel,german=quotes]{csquotes}
\usepackage[language=autobib]{biblatex}
%\usepackage[language=autobib,backend=biber]{biblatex}
\begin{document}
\begin{center}
\scalebox{0.6}{
\begin{tikzpicture}[node distance=2cm, transform shape]
\node[name=c,anchor=north] at (2,-1.5) {};
\node [name=d, anchor=north, draw=black!80, text centered, text width=4.5cm, minimum height = 8cm, rectangle, rounded corners=1mm, fill=gray!0] at ($(c.south)+(-10.6,-0.04)$) {\textbf{I. text text text} \\(text)};
\node [name=e, anchor=north, draw=black!80, text centered, text width=4.5cm, minimum height = 8cm, rectangle, rounded corners=1mm, fill=gray!0] at ($(c.south)+(-4.5375,-0.04)$) {\textbf{II. text text text} \\(text text text text text text text text text)};
\node [name=f, anchor=north, draw, text width=8.6cm, align=center, rectangle, minimum height = 1.25cm, rounded corners=0mm, fill=gray!95] at ($(d.south)+(+0.25,0)$) {\textcolor{white}{this text in bold???}};
\end{tikzpicture}}
\end{center}
\end{document}
答案1
- 对于 mwe 来说,你的序言并不简单。大多数包和库与你的问题无关
- 我不会用
\scalebox
它来减小图像尺寸。而是定义节点样式并确定形状的大小 在节点定位中我将使用
tikz
库positioning
及其语法。node distance = <vertical> and <horisontal>
我将确定节点之间的垂直和水平距离(您的方法并没有错,但是在我看来太复杂了)\documentclass[a4paper]{scrbook} %\usepackage[utf8]{inputenc} it is contained in recent version of latex \usepackage[T1]{fontenc} \usepackage[english,german,ngerman]{babel} \usepackage{textcomp} \usepackage{lmodern} \usepackage{scrlayer-scrpage} \usepackage{microtype} \usepackage{xcolor} \usepackage{tikz} \usetikzlibrary{positioning} \begin{document} \begin{center} \begin{tikzpicture}[ node distance = 0mm and 20mm, box/.style = {draw=black!80, rounded corners, text width=30mm, minimum height=50mm, align=center}, gbox/.style = {box, fill=#1, text width=50mm, minimum height=12mm, font=\bfseries, text=white}, ] \node [name=d, box] {\textbf{I. text text text} \\(text)}; \node [name=e, box, right=of d] {\textbf{II. text text text} \\ (text text text text text text text text text)}; \node [name=f, gbox, below=of d ] {\textcolor{white}{this text in bold???}}; \end{tikzpicture} \end{center} \end{document}