Seite 1 von 2

Minipage: Text oben rechts

Verfasst: Fr 9. Mär 2018, 23:31
von olpo
Hallo,

wie bekomme ich den rechten Text sauber in die obere rechte Ecke gesetzt?
\documentclass{scrartcl}
\begin{document}

\begin{minipage}{11em}
\fbox{\parbox{10em}{Lorem\\ipsum\\dolor\\sit\\amet}}
\end{minipage}
\hfill
\begin{minipage}{15em}
\raggedleft{\fbox{consetetur sadipscing elitr}}
\end{minipage}
 
\end{document}
Danke

Verfasst: Sa 10. Mär 2018, 00:41
von Bartman
\documentclass{scrartcl}
\usepackage{showframe}

\newcommand*{\rightboxtext}{consetetur sadipscing elitr}

\newlength{\leftboxwidth}
\settowidth{\leftboxwidth}{Lorem}
\newlength{\rightboxwidth}
\settowidth{\rightboxwidth}{\rightboxtext}

\begin{document}
\noindent
\fbox{\parbox[tt]{\leftboxwidth}{Lorem\\ipsum\\dolor\\sit\\amet}}
\hfill
\fbox{\parbox{\rightboxwidth}{\rightboxtext}}
\end{document}
Das geht natürlich auch mit der minipage-Umgebung.

Verfasst: Sa 10. Mär 2018, 11:19
von olpo
Danke.
In dem konkreten Fall wird die linke Box allerdings mit \savebox erzeugt.
Und bei \savebox kann ich den Parameter nicht verwenden.
Ich hatte gehofft, die \savebox mit einer minipage oder einer \parbox einzurahmen und dann mit zu positionieren.
[code]\documentclass{scrartcl}
\usepackage{showframe}

\newcommand*{\rightboxtext}{consetetur sadipscing elitr}

\newlength{\leftboxwidth}
\settowidth{\leftboxwidth}{Lorem}
\newlength{\rightboxwidth}
\settowidth{\rightboxwidth}{\rightboxtext}

\begin{document}
\noindent
%\fbox{\parbox{\leftboxwidth}{Lorem\\ipsum\\dolor\\sit\\amet}}
%
\newbox{\foo}
\savebox{\foo}[\leftboxwidth]{Lorem\\ipsum\\dolor\\sit\\amet}
\usebox{\foo}
%
\hfill
\fbox{\parbox{\rightboxwidth}{\rightboxtext}}
\end{document}
[/code]

Verfasst: Sa 10. Mär 2018, 21:44
von olpo
Mein Beispiel oben funktioniert noch nicht:
Die linke Box (foo) erzeugt keinen Zeilenumbruch.

Weiß jemand warum?

Verfasst: Sa 10. Mär 2018, 22:09
von esdd
Mir ist nicht ganz klar, was Du erreichen möchtest. Vielleicht etwas in der Richtung
\documentclass{scrartcl}
\usepackage{showframe}% Anzeigen des Seitenlayouts
\newbox{\foo}
\begin{document}
\savebox{\foo}{%
  \begin{tabular}[t]{@{}l@{}}
    Lorem\\ipsum\\dolor\\sit\\amet
  \end{tabular}%
}
\noindent\fbox{\usebox\foo}%
\hfill
\fbox{%
  \begin{tabular}[t]{@{}l@{}}
    consetetur sadipscing elitr
  \end{tabular}%
}
\end{document}

Verfasst: So 11. Mär 2018, 09:40
von olpo
Hmm, bei dem tätsächlichen Projekt will das noch nicht:
Ich bin dabei komacv-casual.sty zu editieren. Von Zeile 88 bis 126 wird der Titel des CV erzeugt (siehe Code).
\providecommand\@cvtitlecasual{%
\newbox{\@picbox}
\savebox{\@picbox}{%
  \ifundef{\@photoname}{}{% with picture:
    \ifthenelse{%
      \equal{\@photoframe}{frame} \OR
      \equal{\@photoframe}{mframe}
    }{% with frame:
      \fcolorbox{@framecolor}{@framebackcolor}{%
        \includegraphics[width=\@photowidth]{\@photoname}%
      }% end fcolorbox
    }{% without frame:
      \includegraphics[width=\@photowidth]{\@photoname}%
    }% end ifdefstring frame
  }% end ifundef photoname
}% end savebox picbox
\settowidth\@titlepicwidth{\usebox{\@picbox}}
\setlength\@titlenamewidth{\textwidth-\@titlesepwidth-\@titlepicwidth}

  \usebox{\@picbox}%
  \hspace*{\@titlesepwidth}%
  \parbox[b]{\@titlenamewidth}{%
    \raggedleft{\firstnamestyle\firstname}%
    ~{\familynamestyle\familyname}\\
    \raggedleft\color{@firstnamecolor}\rule{\@titlenamewidth}{.25ex}\par
  }% end parbox
  \vspace{\@aftertitlevspace}
  %% optional acadtitle
  \ifdefempty{\acadtitle}{}{%
    \raggedleft\acadtitlestyle{\acadtitle}}\\[2.5em]%
  %% optional quote
  \ifdefempty{\cvquote}{}{%
    {\centering
      \begin{minipage}{\@quotewidth}%
        \centering\quotestyle{\cvquote}
      \end{minipage}\\[\@afterquotevspace]%
    }
  }%
}% end \@cvtitle-casual
In dem ersten Abschnitt wird eine @picbox angelegt und zu Beginn des zweiten Abschnitts mit \usebox{\@picbox} verwendet.
Neben diese @picbox wird eine \parbox gesetzt.

Ich möchte nun erreichen, daß die \parbox in die Ecke oben rechts gesetzt wird.

Verfasst: So 11. Mär 2018, 21:30
von olpo
Das Problem scheint bei der \@picbox zu liegen.
Wenn ich bei die \@picbox gegen unsere \foo box aus dem Mini-Bsp. ersetze, dann wird der Name im Komacv "richtig" oben rechts gesetzt.
Ich kann mir das nicht erklären. Ich dachte immer Box sei Box, unabhängig vom Inhalt.
%%%%%% -->
\newbox{\foo} 
\savebox{\foo}{% 
  \begin{tabular}[t]{@{}l@{}} 
    Lorem\\ipsum\\dolor\\sit\\amet 
  \end{tabular}% 
} 
%%%%%%%%%%%%%
\providecommand\@cvtitletest{%
\newbox{\@picbox}
\savebox{\@picbox}{%
  \ifundef{\@photoname}{}{% with picture:
    \ifthenelse{%
      \equal{\@photoframe}{frame} \OR
      \equal{\@photoframe}{mframe}
    }{% with frame:
      \fcolorbox{@framecolor}{@framebackcolor}{%
        \includegraphics[width=\@photowidth]{\@photoname}%
      }% end fcolorbox
    }{% without frame:
      \includegraphics[width=\@photowidth]{\@photoname}%
    }% end ifdefstring frame
  }% end ifundef photoname
}% end savebox picbox
\settowidth\@titlepicwidth{\usebox{\@picbox}}
\setlength\@titlenamewidth{\textwidth-\@titlesepwidth-\@titlepicwidth}

%%%%% --> usebox austauschen
%  \usebox{\@picbox}
\usebox{\foo}
%%%%%%%%%%%%%%
  \hspace*{\@titlesepwidth}%
  \parbox[b]{\@titlenamewidth}{%
    \raggedleft{\firstnamestyle\firstname}%
    ~{\familynamestyle\familyname}\\
    \raggedleft\color{@firstnamecolor}\rule{\@titlenamewidth}{.25ex}\par
  }% end parbox
  \vspace{\@aftertitlevspace}
  %% optional acadtitle
  \ifdefempty{\acadtitle}{}{%
    \raggedleft\acadtitlestyle{\acadtitle}}\\[2.5em]%
  %% optional quote
  \ifdefempty{\cvquote}{}{%
    {\centering
      \begin{minipage}{\@quotewidth}%
        \centering\quotestyle{\cvquote}
      \end{minipage}\\[\@afterquotevspace]%
    }
  }%
}% end \@cvtitle-test
Wie gesagt versuche ich komacv-casual.sty zu editieren.
https://ctan.org/pkg/komacv?lang=de

Verfasst: Mo 12. Mär 2018, 12:03
von olpo
Ich konnte den Style-Code in das Minimalbeispiel übertragen.
Tatsächlich ist \includegraphics das Problem.
Bei texwelt.de habe ich eine dreckige Lösung gefunden: https://texwelt.de/wissen/fragen/4116/w ... ausrichten

Kann das noch jemand verbessern?
\documentclass{scrartcl}
\usepackage{showframe}
\usepackage{graphicx}

\newbox{\foo}
\newbox{\picbox}

%\savebox{\foo}{%
% \fbox{
%  \begin{tabular}[t]{@{}l@{}}
%    Lorem\\ipsum\\dolor\\sit\\amet
%  \end{tabular}%
%  }
%}

\savebox{\picbox}{%
\fbox{\includegraphics[width=3cm]{jeyre}}
}

\begin{document}
\noindent
\begin{minipage}[t]{0.4\textwidth}
%\usebox{\foo}
\vspace{-\ht\strutbox}
\usebox{\picbox}
\end{minipage}
\hfill
\vspace{-\ht\strutbox}
\fbox{%
    consetetur sadipscing elitr
}
\end{document}

Verfasst: Mo 12. Mär 2018, 12:54
von Gast
olpo hat geschrieben:Bei texwelt.de habe ich eine dreckige Lösung gefunden: https://texwelt.de/wissen/fragen/4116/w ... ausrichten
Wenn Du diese Lösung dreckig findest, warum nimmst Du dann nicht die saubere Lösung aus der am höchsten bewerteten Antwort?

BTW: In den wichtigen Hinweisen unsere Grafikforums gibt es auch diverse Beispiele zur vertikalen Ausrichtung.

Verfasst: Mi 14. Mär 2018, 11:39
von olpo
Mit adjustbox ist das Ergebnis aber auch nicht besser.
Das Bild schließt nicht sauber am oberen Rand.
\documentclass{scrartcl}
\usepackage{showframe}
\usepackage{graphicx}
\usepackage{adjustbox}

\newbox{\picbox}
\savebox{\picbox}{%
\fbox{\adjincludegraphics[valign=t,width=3cm]{jeyre}}
}

\begin{document}
\noindent

\begin{minipage}[t]{0.4\textwidth}
  \usebox{\picbox}
\end{minipage}
\hfill
\begin{minipage}[t]{0.4\textwidth}
  \raggedleft\fbox{consetetur sadipscing elitr}
\end{minipage}

\end{document}