小页面文本和图片对齐

小页面文本和图片对齐

在此处输入图片描述我正在尝试将一些文本和图形 (pgfplots) 对齐在一起。我浏览了一些帖子,找到了一个不错的包调整框这使得文本和图形对齐。但是,在我的例子中,文本现在太高了。我想尝试让它们对齐。我无法想出解决方案。

任何帮助都将不胜感激。这是我的文件。

\usepackage[utf8]{inputenc}
\usepackage[margin=.75in]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\rhead{AP Calculus AB}
\lhead{Mr. Bennett}
\chead{Limits and Continuity}
\cfoot{ Page \thepage}
\usepackage{adjustbox}
\usepackage{pgffor, ifthen}
\usepackage{multicol}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{plotmarks}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes.misc, positioning}
\usetikzlibrary{arrows,shapes,positioning,snakes}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{arrows.meta}
\pgfplotsset{every x tick label/.append style={font=\tiny, yshift=0.5ex}}
\pgfplotsset{every y tick label/.append style={font=\tiny, xshift=0.5ex}}


 \newcommand{\s}{\small}
 \newcommand{\f}{\footnotesize}
 
 \newcommand{\notes}[3][\empty]{%
    \noindent \vspace{10pt}\\
    \foreach \n in {1,...,#2}{%
        \ifthenelse{\equal{#1}{\empty}}
            {\rule{#3}{0.5pt}\\}
            {\rule{#3}{0.5pt}\vspace{#1}\\}
        }
}


\begin{document}

    \adjustbox{valign=t}{\begin{minipage}{.5\textwidth}
    The equation of the function graphed to the right is \(f(x)=\dfrac{2x^2+7x+6}{x^2-4}\).  The coordinates of the hole in the graph are \(\bigg(2,\dfrac{1}{4}\bigg)\)
    \end{minipage}}
    \adjustbox{valign=t}{\begin{minipage}{.5\textwidth}
        \begin{tikzpicture}
            \begin{axis}
                [width=4in,
                    grid style={black!25},
                    axis x line = center,
                    axis y line = center,
                    xmin = -6,   xmax = 10,
                    ymin = -6,  ymax = 10,
                    xtick = {-6,-5,...,10},
                    ytick = {-6,-5,...,10},
                    xlabel={$x$},
                    ylabel={$y$},
                    xlabel style={above right},
                    ylabel style={above right},
                    axis line style={latex-latex},
                    grid=both
                ]
                        \addplot[thick,color=red,domain=2.2:10] {(2*x+3)/(x-2)};
                        \addplot[color=red,thick,domain=-6:1.99] {(2*x+3)/(x-2)};
            
                        \addplot[color=red,mark=*,fill=white,only marks] coordinates {(-2,.25)};
                        \addplot[dashed,thick, samples=50, smooth,domain=0:6,blue] coordinates {(2,-6)(2,10)};
                        \addplot[dashed,thick,samples=50,smooth,domain=-6:10,blue] coordinates {(-6,2)(10,2)};

            \end{axis}
        \end{tikzpicture}
    \end{minipage}}
    \vspace*{.25in}
    
    
    
    
    
\end{document}

答案1

无需使用该adjustbox包即可获得以下对齐:

在此处输入图片描述

彩色矩形仅用于演示目的(蓝色 = 文本区域,红色 = tikzpicture 的边界框,绿色 = 迷你页面),不是由此 MWE 生成的:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=.75in]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\rhead{AP Calculus AB}
\lhead{Mr. Bennett}
\chead{Limits and Continuity}
\cfoot{ Page \thepage}
\usepackage{adjustbox}
\usepackage{pgffor, ifthen}
\usepackage{multicol}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{plotmarks}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes.misc, positioning}
\usetikzlibrary{arrows,shapes,positioning,snakes}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{arrows.meta}
\pgfplotsset{every x tick label/.append style={font=\tiny, yshift=0.5ex}}
\pgfplotsset{every y tick label/.append style={font=\tiny, xshift=0.5ex}}



 \newcommand{\s}{\small}
 \newcommand{\f}{\footnotesize}
 
 \newcommand{\notes}[3][\empty]{%
    \noindent \vspace{10pt}\\
    \foreach \n in {1,...,#2}{%
        \ifthenelse{\equal{#1}{\empty}}
            {\rule{#3}{0.5pt}\\}
            {\rule{#3}{0.5pt}\vspace{#1}\\}
        }
}


\newlength{\mylength}       
\settoheight{\mylength}{T}

\begin{document}

\noindent
\begin{minipage}[t]{.45\textwidth}
    The equation of the function graphed to the right is \(f(x)=\dfrac{2x^2+7x+6}{x^2-4}\).  The coordinates of the hole in the graph are \(\bigg(2,\dfrac{1}{4}\bigg)\)
    \end{minipage}
    \hfill
        \begin{tikzpicture}[baseline={([yshift=-\mylength]current bounding box.north)}]
            \begin{axis}
                [width=4in,
                    grid style={black!25},
                    axis x line = center,
                    axis y line = center,
                    xmin = -6,   xmax = 10,
                    ymin = -6,  ymax = 10,
                    xtick = {-6,-5,...,10},
                    ytick = {-6,-5,...,10},
                    xlabel={$x$},
                    ylabel={$y$},
                    xlabel style={above right},
                    ylabel style={above right},
                    axis line style={latex-latex},
                    grid=both
                ]
                        \addplot[thick,color=red,domain=2.2:10] {(2*x+3)/(x-2)};
                        \addplot[color=red,thick,domain=-6:1.99] {(2*x+3)/(x-2)};
            
                        \addplot[color=red,mark=*,fill=white,only marks] coordinates {(-2,.25)};
                        \addplot[dashed,thick, samples=50, smooth,domain=0:6,blue] coordinates {(2,-6)(2,10)};
                        \addplot[dashed,thick,samples=50,smooth,domain=-6:10,blue] coordinates {(-6,2)(10,2)};

            \end{axis};
        \end{tikzpicture}

    
    
    
    
    
\end{document}

相关内容