我有以下代码:
\documentclass[12pt,a4paper,final,twocolumn]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{tikz}
\usepackage{fontspec}
\usepackage{graphics}
\usetikzlibrary{shapes,snakes}
\usepackage{pgf}
\usepackage[left=2.00cm, right=2.00cm, top=2.00cm, bottom=2.00cm]{geometry}
\setmainfont{Source Sans Pro}
\setsansfont{Source Sans Pro}
\begin{document}
\begin{tikzpicture}
\draw (2,2) circle (2.5cm);
\node[inner sep=0pt] (myfirstpic) at (2,2.6) {\includegraphics[width=.09\textwidth]{info.png}};
\node at (2,1) {{\LARGE Andreas}};
\end{tikzpicture}
\end{document}
这是可行的,但有时我不知道圆圈内放了什么内容。我想知道是否有更简单或更干净的方法来做到这一点。
答案1
\documentclass[12pt,a4paper,final,twocolumn]{article}
\usepackage[margin=2.00cm]{geometry}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{fit}
\begin{document}
\begin{tikzpicture}
\node[inner sep=0pt,above] (n1) {\includegraphics[width=.09\textwidth]{example-image-duck}};
\node [font=\LARGE,below] (n2) {Andreas};
\node [draw, circle, minimum size=5cm, fit= (n1) (n2)] {};
\end{tikzpicture}
\end{document}
圆的尺寸由最小尺寸决定,最小尺寸等于圆的直径。
附录:
不使用fit
库的更简单的解决方案:
\documentclass[12pt,a4paper,final,twocolumn]{article}
\usepackage[margin=2.00cm]{geometry}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[node distance=1mm]
\node[inner sep=0pt,above] (n1) {\includegraphics[width=.09\textwidth]{example-image-duck}};
\node [font=\LARGE, below] (n2) {Andreas};
\draw(0,0) circle[radius=2.5cm];
\end{tikzpicture}
\end{document}
结果与上面相同,圆的宽度现在由圆的半径决定